-
Notifications
You must be signed in to change notification settings - Fork 1
/
fluidsize_test.go
68 lines (56 loc) · 1.16 KB
/
fluidsize_test.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package brewerydb
import (
"io"
"net/http"
"strconv"
"testing"
)
func TestFluidsizeGet(t *testing.T) {
setup()
defer teardown()
data := loadTestData("fluidsize.get.json", t)
defer data.Close()
const id = 5
mux.HandleFunc("/fluidsize/", func(w http.ResponseWriter, r *http.Request) {
checkMethod(t, r, "GET")
checkURLSuffix(t, r, strconv.Itoa(id))
io.Copy(w, data)
})
f, err := client.Fluidsize.Get(id)
if err != nil {
t.Fatal(err)
}
if f.ID != id {
t.Fatalf("Fluidsize ID = %v, want %v", f.ID, id)
}
testBadURL(t, func() error {
_, err := client.Fluidsize.Get(id)
return err
})
}
func TestFluidsizeList(t *testing.T) {
setup()
defer teardown()
data := loadTestData("fluidsize.list.json", t)
defer data.Close()
mux.HandleFunc("/fluidsizes", func(w http.ResponseWriter, r *http.Request) {
checkMethod(t, r, "GET")
io.Copy(w, data)
})
fl, err := client.Fluidsize.List()
if err != nil {
t.Fatal(err)
}
if len(fl) <= 0 {
t.Fatal("Expected >0 fluidsizes")
}
for _, f := range fl {
if f.ID <= 0 {
t.Fatalf("Expected non-zero ID")
}
}
testBadURL(t, func() error {
_, err := client.Fluidsize.List()
return err
})
}