forked from bluemixgaragelondon/cf-blue-green-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
args_test.go
79 lines (61 loc) · 1.89 KB
/
args_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main_test
import (
. "github.com/bluemixgaragelondon/cf-blue-green-deploy"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strings"
)
var _ = Describe("Args", func() {
Context("With an appname only", func() {
args := NewArgs(bgdArgs("appname"))
It("sets the app name", func() {
Expect(args.AppName).To(Equal("appname"))
})
It("does not set the smoke test file", func() {
Expect(args.SmokeTestPath).To(BeZero())
})
It("does not set a manifest", func() {
Expect(args.ManifestPath).To(BeZero())
})
})
Context("With a smoke test and an appname", func() {
args := NewArgs(bgdArgs("appname --smoke-test script/smoke-test"))
It("sets the smoke test file", func() {
Expect(args.SmokeTestPath).To(Equal("script/smoke-test"))
})
It("sets the app name", func() {
Expect(args.AppName).To(Equal("appname"))
})
It("does not set a manifest", func() {
Expect(args.ManifestPath).To(BeZero())
})
})
Context("With an appname smoke test and a manifest", func() {
args := NewArgs(bgdArgs("appname --smoke-test smokey -f manifest.yml"))
It("sets the smoke test file", func() {
Expect(args.SmokeTestPath).To(Equal("smokey"))
})
It("sets the app name", func() {
Expect(args.AppName).To(Equal("appname"))
})
It("sets a manifest", func() {
Expect(args.ManifestPath).To(Equal("manifest.yml"))
})
})
Context("When a global cf flag is set with an app name", func() {
args := NewArgs([]string{"cf", "-v", "blue-green-deploy", "app"})
It("sets the app name", func() {
Expect(args.AppName).To(Equal("app"))
})
})
Context("When the bgd abbreviation is used", func() {
args := NewArgs([]string{"cf", "bgd", "app"})
It("sets the app name", func() {
Expect(args.AppName).To(Equal("app"))
})
})
})
func bgdArgs(argString string) []string {
args := strings.Split(argString, " ")
return append([]string{"cf", "blue-green-deploy"}, args...)
}