on 2daa5e5 help sign in
src/Docker/Client/Types.hs+4−1
since splitsnapshots
unifiedsplit
@@ -520,7 +520,7 @@ data Container = Container
520
520
521instance FromJSON Container where
521instance FromJSON Container where
522 parseJSON (JSON.Object v) =
522 parseJSON (JSON.Object v) =
523− Container <$> (v .: "Id")
523+ Container <$> (v .: "Id" >>= parseContainerID)
524 <*> (v .: "Names")
524 <*> (v .: "Names")
525 <*> (v .: "Image")
525 <*> (v .: "Image")
526 <*> (v .: "ImageID")
526 <*> (v .: "ImageID")
@@ -535,6 +535,9 @@ 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+ parseContainerID v = case (toContainerID v) of
539+ Nothing -> fail "bla"
540+ Just i -> return i
538
541
539 parseJSON _ = fail "Container: Not a JSON object."
542 parseJSON _ = fail "Container: Not a JSON object."
540
543
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 ]