Skip to content

Commit 5437613

Browse files
committed
tests(integration): add BDD client tests
1 parent e4a3134 commit 5437613

21 files changed

Lines changed: 783 additions & 0 deletions

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,7 @@ test-unit:
7979
test-functional:
8080
@echo "Implement functional tests in _tests directory"
8181

82+
test-integration:
83+
$(MAKE) -C _tests/ test-setup test-integration
84+
8285
.PHONY: build clean commit-hook full-clean postgres setup-venv test test-style test-unit test-functional

_tests/.gitkeep

Whitespace-only changes.

_tests/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
test-setup:
3+
go get github.com/onsi/ginkgo/ginkgo
4+
go get github.com/onsi/gomega
5+
6+
test-integration:
7+
go test -v ./...

_tests/apps_test.go

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
package _tests_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Apps", func() {
9+
Context("with a logged-in user", func() {
10+
appName := "apps-test"
11+
12+
BeforeEach(func() {
13+
login(url, testUser, testPassword)
14+
})
15+
16+
It("can't get app info", func() {
17+
output, err := execute("deis info -a %s", appName)
18+
Expect(err).To(HaveOccurred())
19+
Expect(output).To(ContainSubstring("NOT FOUND"))
20+
})
21+
22+
It("can't get app logs", func() {
23+
output, err := execute("deis logs -a %s", appName)
24+
Expect(err).To(HaveOccurred())
25+
Expect(output).To(ContainSubstring("NOT FOUND"))
26+
})
27+
28+
// TODO: this currently returns "Error: json: cannot unmarshal object into Go value of type []interface {}"
29+
XIt("can't run a command in the app environment", func() {
30+
output, err := execute("deis apps:run echo Hello, 世界")
31+
Expect(err).To(HaveOccurred())
32+
Expect(output).To(ContainSubstring("NOT FOUND"))
33+
})
34+
35+
It("can create an app", func() {
36+
output, err := execute("deis apps:create %s", appName)
37+
Expect(err).NotTo(HaveOccurred())
38+
Expect(output).To(SatisfyAll(
39+
ContainSubstring("Creating Application... done, created %s", appName),
40+
ContainSubstring("Git remote deis added"),
41+
ContainSubstring("remote available at ")))
42+
output, err = execute("deis apps:destroy --confirm=%s", appName)
43+
Expect(err).NotTo(HaveOccurred())
44+
Expect(output).To(SatisfyAll(
45+
ContainSubstring("Destroying %s...", appName),
46+
ContainSubstring("done in "),
47+
ContainSubstring("Git remote deis removed")))
48+
})
49+
50+
It("can create an app with no git remote", func() {
51+
output, err := execute("deis apps:create %s --no-remote", appName)
52+
Expect(err).NotTo(HaveOccurred())
53+
Expect(output).To(SatisfyAll(
54+
ContainSubstring("Creating Application... done, created %s", appName),
55+
ContainSubstring("remote available at ")))
56+
Expect(output).NotTo(ContainSubstring("Git remote deis added"))
57+
output, err = execute("deis apps:destroy --app=%s --confirm=%s", appName, appName)
58+
Expect(err).NotTo(HaveOccurred())
59+
Expect(output).To(SatisfyAll(
60+
ContainSubstring("Destroying %s...", appName),
61+
ContainSubstring("done in ")))
62+
Expect(output).NotTo(ContainSubstring("Git remote deis removed"))
63+
})
64+
65+
It("can create an app with a custom buildpack", func() {
66+
output, err := execute("deis apps:create %s --buildpack https://example.com", appName)
67+
Expect(err).NotTo(HaveOccurred())
68+
Expect(output).To(SatisfyAll(
69+
ContainSubstring("Creating Application... done, created %s", appName),
70+
ContainSubstring("Git remote deis added"),
71+
ContainSubstring("remote available at ")))
72+
output, err = execute("deis config:list")
73+
Expect(err).NotTo(HaveOccurred())
74+
Expect(output).To(ContainSubstring("BUILDPACK_URL"))
75+
output, err = execute("deis apps:destroy --app=%s --confirm=%s", appName, appName)
76+
Expect(err).NotTo(HaveOccurred())
77+
Expect(output).To(SatisfyAll(
78+
ContainSubstring("Destroying %s...", appName),
79+
ContainSubstring("done in "),
80+
ContainSubstring("Git remote deis removed")))
81+
})
82+
})
83+
84+
// Context("with a deployed app", func() {
85+
//
86+
// appName := "apps-test"
87+
// repository := "https://github.com/deis/example-go.git"
88+
//
89+
// TODO: can't have an Expect outside an It clause...need to refactor
90+
// output, err := execute("git clone %s", repository)
91+
// Expect(err).NotTo(HaveOccurred())
92+
// Expect(output).To(SatisfyAll(
93+
// ContainSubstring("Cloning into "),
94+
// ContainSubstring("done.")))
95+
// // TODO: change directory to cloned app dir
96+
// output, err = execute("deis apps:create %s", appName)
97+
// Expect(err).NotTo(HaveOccurred())
98+
// Expect(output).To(SatisfyAll(
99+
// ContainSubstring("Creating Application... done, created %s", appName),
100+
// ContainSubstring("Git remote deis added"),
101+
// ContainSubstring("remote available at ")))
102+
// output, err = execute("git push deis master")
103+
// Expect(err).NotTo(HaveOccurred())
104+
// Expect(output).To(SatisfyAll(
105+
// ContainSubstring("-----> Launching..."),
106+
// ContainSubstring("done, %s:v2 deployed to Deis", appName)))
107+
//
108+
// It("can't create an existing app", func() {
109+
// output, err = execute("deis apps:create %s", appName)
110+
// Expect(err).To(HaveOccurred())
111+
// Expect(output).To(ContainSubstring("This field must be unique"))
112+
// })
113+
//
114+
// It("can get app info", func() {
115+
// output, err := execute("deis info")
116+
// Expect(err).NotTo(HaveOccurred())
117+
// Expect(output).To(SatisfyAll(
118+
// HavePrefix("=== %s Application", appName),
119+
// ContainSubstring("=== %s Processes", appName),
120+
// ContainSubstring(".1 up (v"),
121+
// ContainSubstring("=== %s Domains", appName)))
122+
// })
123+
//
124+
// It("can get app logs", func() {
125+
// output, err := execute("deis logs")
126+
// Expect(err).NotTo(HaveOccurred())
127+
// Expect(output).To(SatisfyAll(
128+
// ContainSubstring("%s[deis-controller]: %s created initial release",
129+
// appName, username),
130+
// ContainSubstring("%s[deis-controller]: %s deployed", appName, username),
131+
// ContainSubstring("%s[deis-controller]: %s scaled containers",
132+
// appName, username)))
133+
// })
134+
//
135+
// // TODO: how to test "deis open" which spawns a browser?
136+
// XIt("can open the app's URL", func() {
137+
// _, err := execute("deis open")
138+
// Expect(err).NotTo(HaveOccurred())
139+
// })
140+
//
141+
// It("can't open a bogus app URL", func() {
142+
// output, err := execute("deis open -a bogus-appname")
143+
// Expect(err).To(HaveOccurred())
144+
// Expect(output).To(ContainSubstring("404 NOT FOUND"))
145+
// })
146+
//
147+
// It("can run a command in the app environment", func() {
148+
// output, err := execute("deis apps:run echo Hello, 世界")
149+
// Expect(err).NotTo(HaveOccurred())
150+
// Expect(output).To(SatisfyAll(
151+
// HavePrefix("Running 'echo Hello, 世界'..."),
152+
// HaveSuffix("Hello, 世界\n")))
153+
// })
154+
//
155+
// // TODO: this requires a second user account
156+
// XIt("can transfer the app to another owner", func() {
157+
// })
158+
// })
159+
160+
})

_tests/auth_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package _tests_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Auth", func() {
9+
Context("when logged out", func() {
10+
BeforeEach(func() {
11+
logout()
12+
})
13+
14+
It("won't print the current user", func() {
15+
output, err := execute("deis auth:whoami")
16+
Expect(err).To(HaveOccurred())
17+
Expect(output).To(ContainSubstring("Not logged in."))
18+
Expect(output).NotTo(ContainSubstring(testUser))
19+
})
20+
})
21+
22+
Context("when logged in", func() {
23+
BeforeEach(func() {
24+
login(url, testUser, testPassword)
25+
})
26+
27+
It("can log out", func() {
28+
logout()
29+
})
30+
31+
It("won't register twice", func() {
32+
cmd := "deis register %s --username=%s --password=%s --email=%s"
33+
output, err := execute(cmd, url, testUser, testPassword, testEmail)
34+
Expect(err).To(HaveOccurred())
35+
Expect(output).To(ContainSubstring("Registration failed"))
36+
})
37+
38+
It("prints the current user", func() {
39+
output, err := execute("deis auth:whoami")
40+
Expect(err).NotTo(HaveOccurred())
41+
Expect(output).To(ContainSubstring("You are %s", testUser))
42+
})
43+
44+
It("regenerates the token for the current user", func() {
45+
output, err := execute("deis auth:regenerate")
46+
Expect(err).NotTo(HaveOccurred())
47+
Expect(output).To(ContainSubstring("Token Regenerated"))
48+
})
49+
})
50+
51+
Context("when logged in as an admin", func() {
52+
BeforeEach(func() {
53+
login(url, testAdminUser, testAdminPassword)
54+
})
55+
56+
It("regenerates the token for a specified user", func() {
57+
output, err := execute("deis auth:regenerate -u %s", testUser)
58+
Expect(err).NotTo(HaveOccurred())
59+
Expect(output).To(ContainSubstring("???"))
60+
})
61+
62+
It("regenerates the token for all users", func() {
63+
output, err := execute("deis auth:regenerate --all")
64+
Expect(err).NotTo(HaveOccurred())
65+
Expect(output).To(ContainSubstring("???"))
66+
})
67+
})
68+
})

_tests/builds_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package _tests_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
// . "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Builds", func() {
9+
Context("with a deployed app", func() {
10+
11+
It("can list app builds", func() {
12+
// "deis builds:list --app=%s", app
13+
})
14+
15+
It("can create a build from an existing image (\"deis pull\")", func() {
16+
// "deis builds:create %s --app=%s", image, app
17+
// curl app
18+
// `deis pull %s -a %s --procfile="worker: while true; do echo hi; sleep 3; done"`, image, app
19+
// "deis ps:scale worker=1"
20+
// "deis logs --app=%s", app
21+
})
22+
})
23+
})

_tests/config_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package _tests_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
// . "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Config", func() {
9+
Context("with a deployed app", func() {
10+
11+
XIt("can list environment variables", func() {
12+
// "deis config:set FOO=bar--app=%s"
13+
// "deis run env --app=%s"
14+
// "deis config:list --app=%s"
15+
})
16+
17+
XIt("can set an integer environment variable", func() {
18+
// "deis config:set FOO=10 --app=%s"
19+
// "deis run env --app=%s"
20+
})
21+
22+
XIt("can set an environment variable containing spaces", func() {
23+
// "config:set POWERED_BY=\"the Deis team\" --app={{.AppName}}"
24+
// "deis run env --app=%s"
25+
})
26+
27+
XIt("can set a multi-line environment variable", func() {
28+
// `deis config:set FOO="This is a
29+
//multiline string" --app={{.AppName}}`
30+
// "deis run env --app=%s"
31+
})
32+
33+
XIt("can set an environment variable with multibyte chars", func() {
34+
// "deis config:set FOO=讲台 --app=%s"
35+
// "deis run env --app=%s"
36+
})
37+
38+
XIt("can unset an environment variable", func() {
39+
// "deis config:set FOO=bar --app=%s"
40+
// "deis run env --app=%s"
41+
// "deis config:unset FOO --app=%s"
42+
// "deis run env --app=%s"
43+
})
44+
45+
XIt("can pull the configuration to an .env file", func() {
46+
47+
})
48+
49+
XIt("can push the configuration from an .env file", func() {
50+
51+
})
52+
})
53+
})

_tests/domains_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package _tests_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
// . "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Domains", func() {
9+
Context("with a deployed app", func() {
10+
11+
XIt("can add, list, and remove domains", func() {
12+
// "deis domains:list --app=%s", app
13+
// "deis domains:add %s --app=%s", domain, app
14+
// "deis domains:list --app=%s", app
15+
// curl app at both root and custom domain
16+
// "deis domains:remove %s --app=%s", domain, app
17+
// "deis domains:list --app=%s", app
18+
// curl app at both root and custom domain, custom should fail
19+
})
20+
21+
XIt("can add, list, and remove certs", func() {
22+
// "deis domains:add %s --app=%s", domain, app
23+
// "deis certs:list", app
24+
// "deis certs:add %s %s", certPath, keyPath
25+
// wait for 60 seconds until cert generation is done?
26+
// curl the custom SSL endpoint
27+
// "deis certs:remove %s", domain
28+
// "deis certs:list", app
29+
// curl the custom SSL endpoint, should fail
30+
// curl app at both root and custom domain, custom should fail
31+
// "deis domains:remove %s --app=%s", domain, app
32+
})
33+
})
34+
})

_tests/example-go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 5450cbcdaaf9afe6fadd219c94ac9c449bd62413

_tests/healthcheck_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package _tests_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
// . "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Healthcheck", func() {
9+
// TODO: port test cases from
10+
// https://github.com/deis/deis/blob/master/tests/healthcheck_test.go
11+
})

0 commit comments

Comments
 (0)