forked from convox/rack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
system_test.go
54 lines (41 loc) · 1.24 KB
/
system_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
package client
import (
"net/url"
"testing"
"github.com/convox/rack/test"
"github.com/stretchr/testify/assert"
)
func TestGetSystem(t *testing.T) {
ts := testServer(t,
test.Http{Method: "GET", Path: "/system", Code: 200, Response: System{
Count: 1,
Name: "system",
Status: "running",
Type: "type",
Version: "version",
}},
)
defer ts.Close()
system, err := testClient(t, ts.URL).GetSystem()
assert.NotNil(t, system, "system should not be nil")
assert.NoError(t, err)
assert.Equal(t, 1, system.Count, ".Count should be 1")
assert.Equal(t, "system", system.Name, ".Name should be system")
assert.Equal(t, "running", system.Status, ".Status should be running")
assert.Equal(t, "type", system.Type, ".Type should be type")
assert.Equal(t, "version", system.Version, ".Version should be version")
}
func TestGetSystemFailure(t *testing.T) {
ts := testServer(t,
test.Http{Method: "GET", Path: "/system", Code: 503, Response: Error{
Error: "invalid system",
}},
)
defer ts.Close()
u, _ := url.Parse(ts.URL)
client := New(u.Host, "test", "test")
system, err := client.GetSystem()
assert.Nil(t, system)
assert.NotNil(t, err)
assert.Equal(t, "invalid system", err.Error(), "err should be invalid system")
}