-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstash_tabs_test.go
82 lines (73 loc) · 2.01 KB
/
stash_tabs_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package poeapi
import (
"testing"
)
func TestStashOptionsToQueryParams(t *testing.T) {
opts := GetStashOptions{ID: "1234"}
params := opts.toQueryParams()
expected := "id=1234"
if params != expected {
t.Fatalf("failed to convert stash options to query params. expected %s, got %s",
expected, params)
}
}
func TestGetStash(t *testing.T) {
c := client{
host: testHost,
useSSL: false,
useCache: false,
limiter: newRateLimiter(UnlimitedRate, UnlimitedRate),
httpClient: testClient,
}
_, err := c.GetStashes(GetStashOptions{})
if err != nil {
t.Fatalf("failed to get stashes: %v", err)
}
}
func TestParseStashResponse(t *testing.T) {
resp, err := loadFixture("fixtures/stash.json")
if err != nil {
t.Fatalf("failed to load fixture: %v", err)
}
if _, err = parseStashResponse(resp); err != nil {
t.Fatalf("failed to parse stash response: %v", err)
}
}
func TestParseStashResponseWithInvalidJSON(t *testing.T) {
resp, err := loadFixture("fixtures/invalid.json")
if err != nil {
t.Fatalf("failed to load fixture: %v", err)
}
if _, err = parseStashResponse(resp); err == nil {
t.Fatal("failed to detect invalid json")
}
}
func TestGetLatestStashID(t *testing.T) {
c := client{
ninjaHost: testHost,
useSSL: false,
limiter: newRateLimiter(UnlimitedRate, UnlimitedRate),
httpClient: testClient,
}
if _, err := c.GetLatestStashID(); err != nil {
t.Fatalf("failed to get latest change id: %v", err)
}
}
func TestParseLatestChangeResponse(t *testing.T) {
resp, err := loadFixture("fixtures/latest-change.json")
if err != nil {
t.Fatalf("failed to load fixture: %v", err)
}
if _, err := parseLatestChangeResponse(resp); err != nil {
t.Fatalf("failed to parse latest change: %v", err)
}
}
func TestParseLatestChangeResponseWithInvalidJSON(t *testing.T) {
resp, err := loadFixture("fixtures/invalid.json")
if err != nil {
t.Fatalf("failed to load fixture: %v", err)
}
if _, err := parseLatestChangeResponse(resp); err == nil {
t.Fatal("failed to detect invalid json")
}
}