-
Notifications
You must be signed in to change notification settings - Fork 61
/
args_test.go
123 lines (94 loc) · 3.02 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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())
})
It("does not delete old app instances", func() {
Expect(args.DeleteOldApps).To(BeFalse())
})
})
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())
})
It("does not delete old app instances", func() {
Expect(args.DeleteOldApps).To(BeFalse())
})
})
Context("With an appname smoke test and a manifest", func() {
args := NewArgs(bgdArgs("appname --smoke-test smokey -f custommanifest.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("custommanifest.yml"))
})
It("does not delete old app instances", func() {
Expect(args.DeleteOldApps).To(BeFalse())
})
})
Context("With an appname and a manifest", func() {
args := NewArgs(bgdArgs("appname -f custommanifest.yml"))
It("sets the app name", func() {
Expect(args.AppName).To(Equal("appname"))
})
It("sets a manifest", func() {
Expect(args.ManifestPath).To(Equal("custommanifest.yml"))
})
It("does not delete old app instances", func() {
Expect(args.DeleteOldApps).To(BeFalse())
})
})
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"))
})
})
Context("With an appname and a manifest and the delete-old-apps flag", func() {
args := NewArgs(bgdArgs("appname -f custommanifest.yml --delete-old-apps"))
It("sets the app name", func() {
Expect(args.AppName).To(Equal("appname"))
})
It("sets a manifest", func() {
Expect(args.ManifestPath).To(Equal("custommanifest.yml"))
})
It("deletes old app instances", func() {
Expect(args.DeleteOldApps).To(BeTrue())
})
})
})
func bgdArgs(argString string) []string {
args := strings.Split(argString, " ")
return append([]string{"blue-green-deploy"}, args...)
}