forked from convox/rack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices_test.go
59 lines (47 loc) · 1.48 KB
/
services_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
package main
import (
"testing"
"github.com/convox/rack/client"
"github.com/convox/rack/test"
)
func TestServices(t *testing.T) {
ts := testServer(t,
test.Http{Method: "GET", Path: "/services", Code: 200, Response: client.Services{
client.Service{Name: "syslog-1234", Type: "syslog", Status: "running"},
}},
)
defer ts.Close()
test.Runs(t,
test.ExecRun{
Command: "convox services",
Exit: 0,
Stdout: "NAME TYPE STATUS\nsyslog-1234 syslog running\n",
},
)
}
func TestServicesCreate(t *testing.T) {
ts := testServer(t,
test.Http{Method: "POST", Path: "/services", Body: "name=syslog-1234&type=syslog&url=tcp%2Btls%3A%2F%2Flogs1.example.com%3A12345", Code: 200, Response: client.Service{}},
)
defer ts.Close()
test.Runs(t,
test.ExecRun{
Command: "convox services create syslog --name=syslog-1234 --url=tcp+tls://logs1.example.com:12345",
Exit: 0,
Stdout: "Creating syslog-1234 (syslog: name=\"syslog-1234\" url=\"tcp+tls://logs1.example.com:12345\")... CREATING\n",
},
)
}
func TestServicesDelete(t *testing.T) {
tsd := testServer(t,
test.Http{Method: "DELETE", Path: "/services/syslog-1234", Code: 200, Response: client.Service{}},
)
defer tsd.Close()
test.Runs(t,
test.ExecRun{
Command: "convox services delete syslog-1234",
Exit: 0,
Stdout: "Deleting syslog-1234... DELETING\n",
},
)
}