forked from convox/rack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps_test.go
59 lines (48 loc) · 1.13 KB
/
apps_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
package main
import (
"testing"
"github.com/convox/rack/client"
"github.com/convox/rack/test"
)
func TestApps(t *testing.T) {
ts := testServer(t,
test.Http{Method: "GET", Path: "/apps", Code: 200, Response: client.Apps{
client.App{Name: "sinatra", Status: "running"},
}},
)
defer ts.Close()
test.Runs(t,
test.ExecRun{
Command: "convox apps",
Exit: 0,
Stdout: "APP STATUS\nsinatra running\n",
},
)
}
func TestAppsCreate(t *testing.T) {
ts := testServer(t,
test.Http{Method: "POST", Path: "/apps", Body: "name=foobar", Code: 200, Response: client.App{}},
)
defer ts.Close()
test.Runs(t,
test.ExecRun{
Command: "convox apps create foobar",
Exit: 0,
Stdout: "Creating app foobar... CREATING\n",
},
)
}
func TestAppsCreateFail(t *testing.T) {
ts := testServer(t,
test.Http{Method: "POST", Path: "/apps", Body: "name=foobar", Code: 403, Response: client.Error{Error: "app already exists"}},
)
defer ts.Close()
test.Runs(t,
test.ExecRun{
Command: "convox apps create foobar",
Exit: 1,
Stdout: "Creating app foobar... ",
Stderr: "ERROR: app already exists\n",
},
)
}