fix(web): test for json request
This commit is contained in:
parent
492a959d84
commit
d86db21705
|
@ -10,14 +10,14 @@ func TestJSONRequest(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
data := struct {
|
||||
IP string `json:"ip"`
|
||||
IP string `json:"query"`
|
||||
}{}
|
||||
err := JSONRequest("http://ip.jsontest.com/", &data)
|
||||
err := JSONRequest("http://ip-api.com/json/?fields=query", &data)
|
||||
assert.NoError(err)
|
||||
assert.NotEqual("", data.IP)
|
||||
|
||||
wrongData := ""
|
||||
err = JSONRequest("http://ip.jsontest.com/", &wrongData)
|
||||
err = JSONRequest("http://ip-api.com/json/?fields=query", &wrongData)
|
||||
assert.Error(err)
|
||||
|
||||
wrongData = ""
|
||||
|
|
Loading…
Reference in New Issue