@@ -357,6 +357,65 @@ var _ = Describe("Container Create API ", func() {
357357 Expect (rr .Body ).Should (MatchJSON (jsonResponse ))
358358 })
359359
360+ It ("should set specified NetworkDisabled setting" , func () {
361+ body := []byte (`{
362+ "Image": "test-image",
363+ "NetworkDisabled": true
364+ }` )
365+ req , _ := http .NewRequest (http .MethodPost , "/containers/create" , bytes .NewReader (body ))
366+
367+ // expected network options
368+ netOpt .NetworkSlice = []string {"none" }
369+
370+ service .EXPECT ().Create (gomock .Any (), "test-image" , nil , equalTo (createOpt ), equalTo (netOpt )).Return (
371+ cid , nil )
372+
373+ // handler should return success message with 201 status code.
374+ h .create (rr , req )
375+ Expect (rr ).Should (HaveHTTPStatus (http .StatusCreated ))
376+ Expect (rr .Body ).Should (MatchJSON (jsonResponse ))
377+ })
378+
379+ It ("should set the OomKillDisable option" , func () {
380+ body := []byte (`{
381+ "Image": "test-image",
382+ "HostConfig": {
383+ "OomKillDisable": true
384+ }
385+ }` )
386+ req , _ := http .NewRequest (http .MethodPost , "/containers/create" , bytes .NewReader (body ))
387+
388+ // expected network options
389+ createOpt .OomKillDisable = true
390+
391+ service .EXPECT ().Create (gomock .Any (), "test-image" , nil , equalTo (createOpt ), equalTo (netOpt )).Return (
392+ cid , nil )
393+
394+ // handler should return success message with 201 status code.
395+ h .create (rr , req )
396+ Expect (rr ).Should (HaveHTTPStatus (http .StatusCreated ))
397+ Expect (rr .Body ).Should (MatchJSON (jsonResponse ))
398+ })
399+
400+ It ("should set the MACAddress to a user specified value" , func () {
401+ body := []byte (`{
402+ "Image": "test-image",
403+ "MacAddress": "12:34:56:78:9a:bc"
404+ }` )
405+ req , _ := http .NewRequest (http .MethodPost , "/containers/create" , bytes .NewReader (body ))
406+
407+ // expected network options
408+ netOpt .MACAddress = "12:34:56:78:9a:bc"
409+
410+ service .EXPECT ().Create (gomock .Any (), "test-image" , nil , equalTo (createOpt ), equalTo (netOpt )).Return (
411+ cid , nil )
412+
413+ // handler should return success message with 201 status code.
414+ h .create (rr , req )
415+ Expect (rr ).Should (HaveHTTPStatus (http .StatusCreated ))
416+ Expect (rr .Body ).Should (MatchJSON (jsonResponse ))
417+ })
418+
360419 It ("should return 404 if the image was not found" , func () {
361420 body := []byte (`{"Image": "test-image"}` )
362421 req , _ := http .NewRequest (http .MethodPost , "/containers/create" , bytes .NewReader (body ))
0 commit comments