@@ -173,6 +173,19 @@ testConnectNetwork =
174 networkMode (Network mode _) = mode
174 networkMode (Network mode _) = mode
176+testDisconnectNetwork :: IO ()
177+testDisconnectNetwork =
179+ containerId <- fromRight =<< createContainer (defaultCreateOpts (testImageName <> ":latest")) Nothing
180+ res <- disconnectNetwork (fromJust $ toNetworkID "bridge") (defaultDisconnectConfig $ fromContainerID containerId)
181+ lift $ assertBool ("disconnecting network, unexpected status: " ++ show res) $ isRight res
182+ details <- fromRight =<< inspectContainer containerId
183+ _ <- deleteContainer defaultContainerDeleteOpts containerId
184+ let networks = networkMode <$> (networkSettingsNetworks . networkSettings) details
185+ lift $ assertBool "disconnecting network failed" $ null networks
187+ networkMode (Network mode _) = mode
176testLogDriverOptionsJson :: TestTree
189testLogDriverOptionsJson :: TestTree
177testLogDriverOptionsJson = testGroup "Testing LogDriverOptions JSON" [test1, test2, test3]
190testLogDriverOptionsJson = testGroup "Testing LogDriverOptions JSON" [test1, test2, test3]
@@ -265,6 +278,17 @@ testNetworkingConfigJson = testGroup "Testing NetworkingConfig JSON" [testSample
281+testDisconnectConfigJson :: TestTree
282+testDisconnectConfigJson = testGroup "Testing DisconnectConfig JSON" [testSampleEncode]
285+ let config = DisconnectConfig "mycontainer" True
286+ in testCase "Test toJSON" $ assert $ JSON.toJSON config ==
288+ [ "Container" .= ("mycontainer" :: Text)
268integrationTests :: TestTree
292integrationTests :: TestTree
269integrationTests =
293integrationTests =
270 testGroup
294 testGroup
@@ -281,6 +305,7 @@ integrationTests =
281 , testCase "List networks" testListNetworks
305 , testCase "List networks" testListNetworks
282 , testCase "Inspect a network" testInspectNetwork
306 , testCase "Inspect a network" testInspectNetwork
283 , testCase "Connect a container to a network" testConnectNetwork
307 , testCase "Connect a container to a network" testConnectNetwork
308+ , testCase "Disconnect a container from a network" testDisconnectNetwork
286jsonTests :: TestTree
311jsonTests :: TestTree
@@ -294,6 +319,7 @@ jsonTests =
294 , testEntrypointJson
319 , testEntrypointJson
295 , testEnvVarJson
320 , testEnvVarJson
296 , testNetworkingConfigJson
321 , testNetworkingConfigJson
322+ , testDisconnectConfigJson
299setup :: IO ()
325setup :: IO ()