|
1 | 1 | package verbose |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | 4 | "github.com/deis/deis/tests/integration-utils" |
| 5 | + "github.com/deis/deis/tests/utils" |
6 | 6 | "testing" |
7 | 7 | ) |
8 | 8 |
|
9 | 9 | func appsSetup(t *testing.T) *itutils.DeisTestConfig { |
10 | | - cfg := itutils.GlobalSetup(t) |
| 10 | + cfg := itutils.GetGlobalConfig() |
| 11 | + cfg.ExampleApp = itutils.GetRandomApp() |
| 12 | + cmd := itutils.GetCommand("auth", "login") |
| 13 | + itutils.Execute(t, cmd, cfg, false, "") |
| 14 | + cmd = itutils.GetCommand("git", "clone") |
| 15 | + itutils.Execute(t, cmd, cfg, false, "") |
11 | 16 | return cfg |
12 | 17 | } |
13 | 18 |
|
14 | | -func keysAddTest(t *testing.T, params *itutils.DeisTestConfig) { |
15 | | - cmd := itutils.GetCommand("keys", "add") |
| 19 | +func appsCreateTest(t *testing.T, params *itutils.DeisTestConfig) { |
| 20 | + cmd := itutils.GetCommand("apps", "create") |
| 21 | + if err := utils.Chdir(params.ExampleApp); err != nil { |
| 22 | + t.Fatalf("Failed:\n%v", err) |
| 23 | + } |
16 | 24 | itutils.Execute(t, cmd, params, false, "") |
17 | | - itutils.Execute(t, cmd, params, true, "Uploading deis to Deis...400 BAD REQUEST") |
| 25 | + itutils.Execute(t, cmd, params, true, "Deis remote already exists") |
| 26 | + |
| 27 | + if err := utils.Chdir(".."); err != nil { |
| 28 | + t.Fatalf("Failed:\n%v", err) |
| 29 | + } |
18 | 30 | } |
19 | 31 |
|
20 | | -func keysListTest(t *testing.T, params *itutils.DeisTestConfig) { |
21 | | - cmd := itutils.GetCommand("keys", "list") |
| 32 | +func appsRunTest(t *testing.T, params *itutils.DeisTestConfig) { |
| 33 | + cmd := itutils.GetCommand("apps", "run") |
| 34 | + if err := utils.Chdir(params.ExampleApp); err != nil { |
| 35 | + t.Fatalf("Failed:\n%v", err) |
| 36 | + } |
22 | 37 | itutils.Execute(t, cmd, params, false, "") |
| 38 | + |
| 39 | + if err := utils.Chdir(".."); err != nil { |
| 40 | + t.Fatalf("Failed:\n%v", err) |
| 41 | + } |
| 42 | + itutils.Execute(t, cmd, params, true, "Could not find deis remote in `git remote -v`") |
| 43 | +} |
| 44 | + |
| 45 | +func appsDestroyTest(t *testing.T, params *itutils.DeisTestConfig) { |
| 46 | + cmd := itutils.GetCommand("apps", "destroy") |
| 47 | + if err := utils.Chdir(params.ExampleApp); err != nil { |
| 48 | + t.Fatalf("Failed:\n%v", err) |
| 49 | + } |
| 50 | + itutils.Execute(t, cmd, params, false, "") |
| 51 | + itutils.Execute(t, cmd, params, true, "400 BAD REQUEST") |
| 52 | + if err := utils.Chdir(".."); err != nil { |
| 53 | + t.Fatalf("Failed:\n%v", err) |
| 54 | + } |
| 55 | + if err := utils.Rmdir(params.ExampleApp); err != nil { |
| 56 | + t.Fatalf("Failed:\n%v", err) |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +func appsListTest(t *testing.T, params *itutils.DeisTestConfig, notflag bool) { |
| 61 | + cmd := itutils.GetCommand("apps", "list") |
| 62 | + itutils.CheckList(t, params, cmd, params.AppName, notflag) |
23 | 63 | } |
24 | 64 |
|
25 | | -func keysRemoveTest(t *testing.T, params *itutils.DeisTestConfig) { |
26 | | - cmd := itutils.GetCommand("keys", "remove") |
| 65 | +func appsLogsTest(t *testing.T, params *itutils.DeisTestConfig) { |
| 66 | + cmd := itutils.GetCommand("apps", "logs") |
| 67 | + cmd1 := itutils.GetCommand("git", "push") |
| 68 | + itutils.Execute(t, cmd, params, true, "204 NO CONTENT") |
| 69 | + if err := utils.Chdir(params.ExampleApp); err != nil { |
| 70 | + t.Fatalf("Failed:\n%v", err) |
| 71 | + } |
| 72 | + itutils.Execute(t, cmd1, params, false, "") |
27 | 73 | itutils.Execute(t, cmd, params, false, "") |
28 | | - itutils.Execute(t, cmd, params, true, "Not found") |
| 74 | + if err := utils.Chdir(".."); err != nil { |
| 75 | + t.Fatalf("Failed:\n%v", err) |
| 76 | + } |
29 | 77 | } |
30 | 78 |
|
31 | | -func TestKeys(t *testing.T) { |
32 | | - params := keysSetup(t) |
33 | | - keysAddTest(t, params) |
34 | | - keysListTest(t, params) |
35 | | - keysRemoveTest(t, params) |
| 79 | +func appsInfoTest(t *testing.T, params *itutils.DeisTestConfig) { |
| 80 | + cmd := itutils.GetCommand("apps", "info") |
| 81 | + itutils.Execute(t, cmd, params, false, "") |
| 82 | +} |
| 83 | + |
| 84 | +func appsOpenTest(t *testing.T, params *itutils.DeisTestConfig) { |
| 85 | + itutils.Curl(t, "http://"+params.AppName+"."+params.HostName, params.ExampleApp) |
| 86 | +} |
| 87 | + |
| 88 | +func TestApps(t *testing.T) { |
| 89 | + params := appsSetup(t) |
| 90 | + appsCreateTest(t, params) |
| 91 | + appsListTest(t, params, false) |
| 92 | + appsLogsTest(t, params) |
| 93 | + appsInfoTest(t, params) |
| 94 | + appsRunTest(t, params) |
| 95 | + appsOpenTest(t, params) |
| 96 | + appsDestroyTest(t, params) |
| 97 | + appsListTest(t, params, true) |
| 98 | + |
36 | 99 | } |
0 commit comments