fix(web): test for json request

This commit is contained in:
Geno 2021-09-10 23:52:30 +02:00
parent 492a959d84
commit d86db21705
1 changed files with 3 additions and 3 deletions

View File

@ -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 = ""