Skip to content

Commit a72e9ae

Browse files
committed
test(label-cmd): add Label model test
1 parent 5fc9ce3 commit a72e9ae

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

api/appsettings_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,17 @@ CPU: 40%`)
3030
t.Errorf("Expected:\n\n%s\n\nGot:\n\n%s", expected2, a2.String())
3131
}
3232
}
33+
34+
func TestLabelsString(t *testing.T) {
35+
data := Labels{
36+
"git_repo": "https://github.com/deis/controller-sdk-go",
37+
"team": "deis",
38+
}
39+
40+
expected := strings.TrimSpace(`git_repo: https://github.com/deis/controller-sdk-go
41+
team: deis`)
42+
43+
if strings.TrimSpace(data.String()) != expected {
44+
t.Errorf("Expected:\n\n%s\n\nGot:\n\n%s", expected, data.String())
45+
}
46+
}

appsettings/appsettings_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const appSettingsFixture string = `
2020
"routable": true,
2121
"whitelist": ["1.2.3.4", "0.0.0.0/0"],
2222
"autoscale": {"cmd": {"min": 3, "max": 8, "cpu_percent": 40}},
23+
"label": {"git_repo": "https://github.com/deis/controller-sdk-go", "team" : "deis"},
2324
"created": "2014-01-01T00:00:00UTC",
2425
"updated": "2014-01-01T00:00:00UTC",
2526
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -34,14 +35,15 @@ const appSettingsUnsetFixture string = `
3435
"routable": true,
3536
"whitelist": ["1.2.3.4", "0.0.0.0/0"],
3637
"autoscale": {"cmd": {"min": 3, "max": 8, "cpu_percent": 40}},
38+
"label": {"git_repo": "https://github.com/deis/controller-sdk-go", "team" : "deis"},
3739
"created": "2014-01-01T00:00:00UTC",
3840
"updated": "2014-01-01T00:00:00UTC",
3941
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
4042
}
4143
`
4244

43-
const appSettingsSetExpected string = `{"maintenance":true,"routable":true,"whitelist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}}}`
44-
const appSettingsUnsetExpected string = `{"maintenance":true,"routable":true,"whitelist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}}}`
45+
const appSettingsSetExpected string = `{"maintenance":true,"routable":true,"whitelist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/deis/controller-sdk-go","team":"deis"}}`
46+
const appSettingsUnsetExpected string = `{"maintenance":true,"routable":true,"whitelist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/deis/controller-sdk-go","team":"deis"}}`
4547

4648
var trueVar = true
4749

@@ -138,6 +140,10 @@ func TestAppSettingsSet(t *testing.T) {
138140
CPUPercent: 40,
139141
},
140142
},
143+
Label: map[string]interface{}{
144+
"git_repo": "https://github.com/deis/controller-sdk-go",
145+
"team": "deis",
146+
},
141147
Created: "2014-01-01T00:00:00UTC",
142148
Updated: "2014-01-01T00:00:00UTC",
143149
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
@@ -154,6 +160,10 @@ func TestAppSettingsSet(t *testing.T) {
154160
CPUPercent: 40,
155161
},
156162
},
163+
Label: map[string]interface{}{
164+
"git_repo": "https://github.com/deis/controller-sdk-go",
165+
"team": "deis",
166+
},
157167
}
158168

159169
actual, err := Set(deis, "example-go", appSettingsVars)
@@ -192,6 +202,10 @@ func TestAppSettingsUnset(t *testing.T) {
192202
CPUPercent: 40,
193203
},
194204
},
205+
Label: map[string]interface{}{
206+
"git_repo": "https://github.com/deis/controller-sdk-go",
207+
"team": "deis",
208+
},
195209
Created: "2014-01-01T00:00:00UTC",
196210
Updated: "2014-01-01T00:00:00UTC",
197211
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
@@ -208,6 +222,10 @@ func TestAppSettingsUnset(t *testing.T) {
208222
CPUPercent: 40,
209223
},
210224
},
225+
Label: map[string]interface{}{
226+
"git_repo": "https://github.com/deis/controller-sdk-go",
227+
"team": "deis",
228+
},
211229
}
212230

213231
actual, err := Set(deis, "unset-test", appSettingsVars)
@@ -246,6 +264,10 @@ func TestAppSettingsList(t *testing.T) {
246264
CPUPercent: 40,
247265
},
248266
},
267+
Label: map[string]interface{}{
268+
"git_repo": "https://github.com/deis/controller-sdk-go",
269+
"team": "deis",
270+
},
249271
Created: "2014-01-01T00:00:00UTC",
250272
Updated: "2014-01-01T00:00:00UTC",
251273
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",

0 commit comments

Comments
 (0)