-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuilds_test.go
More file actions
79 lines (69 loc) · 2.1 KB
/
builds_test.go
File metadata and controls
79 lines (69 loc) · 2.1 KB
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
// +build integration
package tests
import (
"bytes"
"fmt"
"os/exec"
"strings"
"testing"
"text/template"
"github.com/deis/deis/tests/integration-utils"
"github.com/deis/deis/tests/utils"
)
func buildSetup(t *testing.T) *itutils.DeisTestConfig {
cfg := itutils.GetGlobalConfig()
cfg.ExampleApp = itutils.GetRandomApp()
cfg.AppName = "buildsample"
cmd := itutils.GetCommand("auth", "login")
itutils.Execute(t, cmd, cfg, false, "")
cmd = itutils.GetCommand("git", "clone")
itutils.Execute(t, cmd, cfg, false, "")
cmd = itutils.GetCommand("apps", "create")
cmd1 := itutils.GetCommand("git", "push")
cmd2 := itutils.GetCommand("git", "add")
cmd3 := itutils.GetCommand("git", "commit")
if err := utils.Chdir(cfg.ExampleApp); err != nil {
t.Fatalf("Failed:\n%v", err)
}
itutils.Execute(t, cmd, cfg, false, "")
itutils.Execute(t, cmd1, cfg, false, "")
if err := utils.CreateFile(cfg.ExampleApp); err != nil {
t.Fatalf("Failed:\n%v", err)
}
itutils.Execute(t, cmd2, cfg, false, "")
itutils.Execute(t, cmd3, cfg, false, "")
itutils.Execute(t, cmd1, cfg, false, "")
if err := utils.Chdir(".."); err != nil {
t.Fatalf("Failed:\n%v", err)
}
return cfg
}
func buildsListTest(t *testing.T, params *itutils.DeisTestConfig) {
Deis := "/usr/local/bin/deis "
cmd := itutils.GetCommand("builds", "list")
var cmdBuf bytes.Buffer
tmpl := template.Must(template.New("cmd").Parse(cmd))
if err := tmpl.Execute(&cmdBuf, params); err != nil {
t.Fatal(err)
}
cmdString := cmdBuf.String()
fmt.Println(cmdString)
cmdl := exec.Command("sh", "-c", Deis+cmdString)
if stdout, _, err := utils.RunCommandWithStdoutStderr(cmdl); err != nil {
t.Fatalf("Failed:\n%v", err)
} else {
ImageId := strings.Split(stdout.String(), "\n")[2]
params.ImageId = strings.Fields(ImageId)[0]
}
}
func buildsCreateTest(t *testing.T, params *itutils.DeisTestConfig) {
cmd := itutils.GetCommand("builds", "create")
itutils.Execute(t, cmd, params, false, "")
}
func TestBuilds(t *testing.T) {
params := buildSetup(t)
buildsListTest(t, params)
buildsCreateTest(t, params)
appsOpenTest(t, params)
itutils.AppsDestroyTest(t, params)
}