Skip to content

Commit b196e69

Browse files
committed
chore(controller-sdk-go): add lifecycle test cases
1 parent e9369b6 commit b196e69

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

config/config_test.go

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ const configFixtureV1 string = `
4040
"username": "bob"
4141
}
4242
},
43+
"lifecycle": {
44+
"web": {
45+
"postStart": {
46+
"httpGet": {
47+
"path": "/",
48+
"port": 5001
49+
}
50+
}
51+
}
52+
},
4353
"created": "2014-01-01T00:00:00UTC",
4454
"updated": "2014-01-01T00:00:00UTC",
4555
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -73,6 +83,16 @@ const configFixtureV2 string = `
7383
"username": "bob"
7484
}
7585
},
86+
"lifecycle": {
87+
"web": {
88+
"postStart": {
89+
"httpGet": {
90+
"path": "/",
91+
"port": 5001
92+
}
93+
}
94+
}
95+
},
7696
"created": "2014-01-01T00:00:00UTC",
7797
"updated": "2014-01-01T00:00:00UTC",
7898
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -109,7 +129,7 @@ const configSetRefsFixture string = `
109129
`
110130

111131
const (
112-
configSetExpected string = `{"values":[{"group":"global","name":"NEW_URL2","value":"http://localhost:8080/"},{"ptype":"web","name":"NEW_URL","value":"http://localhost:8080"}],"limits":{"web":"std1.xlarge.c1m1"},"tags":{"web":{"test":"tests"}},"registry":{"web":{"username":"bob"}}}`
132+
configSetExpected string = `{"values":[{"group":"global","name":"NEW_URL2","value":"http://localhost:8080/"},{"ptype":"web","name":"NEW_URL","value":"http://localhost:8080"}],"limits":{"web":"std1.xlarge.c1m1"},"lifecycle":{"web":{"postStart":{"httpGet":{"path":"/","port":5001}}}},"tags":{"web":{"test":"tests"}},"registry":{"web":{"username":"bob"}}}`
113133
configUnsetExpected string = `{"values":[{"group":"global","name":"TEST","value":""}],"limits":{"web":null},"tags":{"web":{"test":null}},"registry":{"web":{"username":null}}}`
114134
configSetRefsExpected string = `{"values_refs":{"web":["myconfig1"]}}`
115135
)
@@ -238,6 +258,19 @@ func TestConfigSet(t *testing.T) {
238258
"username": "bob",
239259
},
240260
},
261+
Lifecycle: map[string]*api.Lifecycle{
262+
"web": {
263+
PostStart: func() **api.LifecycleHandler {
264+
handler := &api.LifecycleHandler{
265+
HTTPGet: &api.HTTPGetAction{
266+
Path: "/",
267+
Port: 5001,
268+
},
269+
}
270+
return &handler
271+
}(),
272+
},
273+
},
241274
Created: "2014-01-01T00:00:00UTC",
242275
Updated: "2014-01-01T00:00:00UTC",
243276
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
@@ -273,6 +306,19 @@ func TestConfigSet(t *testing.T) {
273306
"username": "bob",
274307
},
275308
},
309+
Lifecycle: map[string]*api.Lifecycle{
310+
"web": {
311+
PostStart: func() **api.LifecycleHandler {
312+
handler := &api.LifecycleHandler{
313+
HTTPGet: &api.HTTPGetAction{
314+
Path: "/",
315+
Port: 5001,
316+
},
317+
}
318+
return &handler
319+
}(),
320+
},
321+
},
276322
}
277323

278324
actual, err := Set(drycc, "example-go", configVars, true)
@@ -384,6 +430,19 @@ func TestConfigList(t *testing.T) {
384430
"username": "bob",
385431
},
386432
},
433+
Lifecycle: map[string]*api.Lifecycle{
434+
"web": {
435+
PostStart: func() **api.LifecycleHandler {
436+
handler := &api.LifecycleHandler{
437+
HTTPGet: &api.HTTPGetAction{
438+
Path: "/",
439+
Port: 5001,
440+
},
441+
}
442+
return &handler
443+
}(),
444+
},
445+
},
387446
Created: "2014-01-01T00:00:00UTC",
388447
Updated: "2014-01-01T00:00:00UTC",
389448
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",

0 commit comments

Comments
 (0)