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)
|
assert := assert.New(t)
|
||||||
|
|
||||||
data := struct {
|
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.NoError(err)
|
||||||
assert.NotEqual("", data.IP)
|
assert.NotEqual("", data.IP)
|
||||||
|
|
||||||
wrongData := ""
|
wrongData := ""
|
||||||
err = JSONRequest("http://ip.jsontest.com/", &wrongData)
|
err = JSONRequest("http://ip-api.com/json/?fields=query", &wrongData)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
wrongData = ""
|
wrongData = ""
|
||||||
|
|
Loading…
Reference in New Issue