on master help sign in
Add test for listing containers
0751b70Deni Bertovic
src/Docker/Client/Types.hs−1
@@ -535,7 +535,6 @@ instance FromJSON Container where
535 parseNetworks (JSON.Object v) =
535 parseNetworks (JSON.Object v) =
536 (v .: "Networks") >>= parseJSON
536 (v .: "Networks") >>= parseJSON
537 parseNetworks _ = fail "Container NetworkSettings: Not a JSON object."
537 parseNetworks _ = fail "Container NetworkSettings: Not a JSON object."
538−
539 parseJSON _ = fail "Container: Not a JSON object."
538 parseJSON _ = fail "Container: Not a JSON object."
540
539
541-- | Represents the status of the container life cycle.
540-- | Represents the status of the container life cycle.
tests/tests.hs+8
@@ -69,6 +69,13 @@ testFindImage =
69 where
69 where
70 imageFullName = testImageName <> ":latest"
70 imageFullName = testImageName <> ":latest"
71
71
72+testListContainers :: IO ()
73+testListContainers =
74+ runDocker $
75+ do res <- listContainers defaultListOpts
76+ liftIO $ print res
77+ lift $ assert $ isRight res
78+
72testBuildFromDockerfile :: IO ()
79testBuildFromDockerfile :: IO ()
73testBuildFromDockerfile = do
80testBuildFromDockerfile = do
74 cur <- getCurrentDirectory
81 cur <- getCurrentDirectory
@@ -170,6 +177,7 @@ integrationTests =
170 [ testCase "Get docker version" testDockerVersion
177 [ testCase "Get docker version" testDockerVersion
171 , testCase "Build image from Dockerfile" testBuildFromDockerfile
178 , testCase "Build image from Dockerfile" testBuildFromDockerfile
172 , testCase "Find image by name" testFindImage
179 , testCase "Find image by name" testFindImage
180+ , testCase "List containers" testListContainers
173 , testCase "Run a dummy container and read its log" testRunAndReadLog
181 , testCase "Run a dummy container and read its log" testRunAndReadLog
174 , testCase "Try to stop a container that doesn't exist" testStopNonexisting
182 , testCase "Try to stop a container that doesn't exist" testStopNonexisting
175 ]
183 ]