-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_test.go
More file actions
45 lines (34 loc) · 743 Bytes
/
api_test.go
File metadata and controls
45 lines (34 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package greatschools
import "testing"
import "io/ioutil"
import "encoding/json"
import Ω "github.com/onsi/gomega"
const (
testLat = 33.39657
testLon = -112.03422
testLevel = "e"
httpProxyURL = "97.77.104.22"
filePath = "test/test.json"
)
func TestAPIWithProxy(t *testing.T) {
Ω.RegisterTestingT(t)
expectedJSON, err := ioutil.ReadFile(filePath)
if err != nil {
t.Fatal(err.Error())
}
c := New()
resp, err := c.GetSchools(&Request{
Lat: testLat,
Lon: testLon,
Level: testLevel,
Proxy: httpProxyURL,
})
if err != nil {
t.Fatal(err.Error())
}
data, err := json.Marshal(resp)
if err != nil {
t.Fatal(err.Error())
}
Ω.Ω(data).Should(Ω.MatchJSON(expectedJSON), "JSON Mismatch")
}