Skip to content

Commit 3a6cd62

Browse files
committed
Merge pull request #126 from arschles/config-test
feat(_tests): add config tests
2 parents 5502cf5 + b668dd2 commit 3a6cd62

4 files changed

Lines changed: 66 additions & 39 deletions

File tree

_tests/apps_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package _tests_test
22

33
import (
4-
"fmt"
54
. "github.com/onsi/ginkgo"
65
. "github.com/onsi/gomega"
7-
"math/rand"
86
)
97

10-
func getRandAppName() string {
11-
return fmt.Sprintf("apps-test-%d", rand.Int())
12-
}
13-
148
var _ = Describe("Apps", func() {
159
app1Name := getRandAppName()
1610
app2Name := getRandAppName()

_tests/config_test.go

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,77 @@ package _tests_test
22

33
import (
44
. "github.com/onsi/ginkgo"
5-
// . "github.com/onsi/gomega"
5+
. "github.com/onsi/gomega"
66
)
77

88
var _ = Describe("Config", func() {
99
Context("with a deployed app", func() {
10+
appName := getRandAppName()
11+
BeforeEach(func() {
12+
login(url, testUser, testPassword)
13+
})
14+
15+
It("can create a new app", func() {
16+
output, err := execute("deis apps:create %s", appName)
17+
Expect(err).NotTo(HaveOccurred())
18+
Expect(output).To(SatisfyAll(
19+
ContainSubstring("Creating Application... done, created %s", appName),
20+
ContainSubstring("Git remote deis added"),
21+
ContainSubstring("remote available at ")))
22+
})
23+
24+
It("can list environment variables", func() {
25+
out, err := execute("deis config:set FOO=bar -a %s", appName)
26+
Expect(err).NotTo(HaveOccurred())
27+
Expect(out).To(SatisfyAll(
28+
ContainSubstring("Creating config... done"),
29+
ContainSubstring("FOO bar"),
30+
ContainSubstring("=== %s Config", appName),
31+
))
32+
out, err = execute("deis config:list -a %s", appName)
33+
Expect(err).NotTo(HaveOccurred())
34+
Expect(out).To(SatisfyAll(
35+
ContainSubstring("=== %s Config", appName),
36+
ContainSubstring("FOO bar"),
37+
))
38+
// TODO: the following won't work as-is because there is no app running
39+
// "deis run env -a %s"
1040

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"
1541
})
1642

17-
XIt("can set an integer environment variable", func() {
18-
// "deis config:set FOO=10 --app=%s"
19-
// "deis run env --app=%s"
43+
It("can set an integer environment variable", func() {
44+
out, err := execute("deis config:set FOO=1 -a %s", appName)
45+
Expect(err).NotTo(HaveOccurred())
46+
Expect(out).To(ContainSubstring("FOO 1"))
2047
})
2148

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"
49+
It("can set an environment variable containing spaces", func() {
50+
out, err := execute(`deis config:set POWERED_BY=the\ Deis\ team -a %s`, appName)
51+
Expect(err).NotTo(HaveOccurred())
52+
Expect(out).To(ContainSubstring("POWERED_BY the Deis team"))
2553
})
2654

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"
55+
It("can set a multi-line environment variable", func() {
56+
out, err := execute(`deis config:set FOO=This\ is\ a\
57+
multiline\ string -a %s`, appName)
58+
Expect(err).NotTo(HaveOccurred())
59+
Expect(out).To(ContainSubstring(`FOO This\ is\ a\
60+
multiline\ string`))
3161
})
3262

33-
XIt("can set an environment variable with multibyte chars", func() {
34-
// "deis config:set FOO=讲台 --app=%s"
35-
// "deis run env --app=%s"
63+
It("can set an environment variable with multibyte chars", func() {
64+
out, err := execute("deis config:set FOO=讲台 -a %s", appName)
65+
Expect(err).NotTo(HaveOccurred())
66+
Expect(out).To(ContainSubstring("FOO 讲台"))
3667
})
3768

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"
69+
It("can unset an environment variable", func() {
70+
out, err := execute("deis config:set FOO=bar -a %s", appName)
71+
Expect(err).NotTo(HaveOccurred())
72+
Expect(out).To(ContainSubstring("FOO bar"))
73+
out, err = execute("deis config:unset FOO -a %s", appName)
74+
Expect(err).NotTo(HaveOccurred())
75+
Expect(out).NotTo(ContainSubstring("FOO"))
4376
})
4477

4578
XIt("can pull the configuration to an .env file", func() {

_tests/package.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
// Package _tests contains integration tests for the Deis open source PaaS.
22
package _tests
3-
4-
import (
5-
"github.com/onsi/ginkgo/config"
6-
"math/rand"
7-
)
8-
9-
func init() {
10-
rand.Seed(config.GinkgoConfig.RandomSeed)
11-
}

_tests/tests_suite_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package _tests_test
33
import (
44
"bytes"
55
"fmt"
6+
"math/rand"
67
"os"
78
"os/exec"
89
"os/user"
@@ -16,6 +17,14 @@ import (
1617
"testing"
1718
)
1819

20+
func init() {
21+
rand.Seed(GinkgoConfig.RandomSeed)
22+
}
23+
24+
func getRandAppName() string {
25+
return fmt.Sprintf("apps-test-%d", rand.Int())
26+
}
27+
1928
func TestTests(t *testing.T) {
2029
RegisterFailHandler(Fail)
2130
RunSpecs(t, "Tests Suite")
@@ -33,7 +42,7 @@ var (
3342

3443
var _ = BeforeSuite(func() {
3544
workflowHost := os.Getenv("DEIS_WORKFLOW_SERVICE_HOST")
36-
workflowPort := os.Getenv("DEIS_WORKFLOW_SERVICE_HOST")
45+
workflowPort := os.Getenv("DEIS_WORKFLOW_SERVICE_PORT")
3746
Expect(workflowHost).ShouldNot(BeEmpty())
3847
Expect(workflowPort).ShouldNot(BeEmpty())
3948
Expect("../client/deis").Should(BeAnExistingFile())

0 commit comments

Comments
 (0)