on master help sign in
Add test for listing containers

We have to start a container before running this test since it will pass regardless if there are no containers

commit0751b704bdf7c96dd26614bf652998badc2a238d authorDeni Bertovic <deni@denibertovic.com> dateThu 16 Nov 2017, 23:54 (9 years ago) parent966b66d
2 files changed+8−1
src/Docker/Client/Types.hs−1 tests/tests.hs+8
src/Docker/Client/Types.hs−1
@@ -535,7 +535,6 @@ instance FromJSON Container where
535535 parseNetworks (JSON.Object v) =
536536 (v .: "Networks") >>= parseJSON
537537 parseNetworks _ = fail "Container NetworkSettings: Not a JSON object."
538−
539538 parseJSON _ = fail "Container: Not a JSON object."
540539
541540-- | Represents the status of the container life cycle.
tests/tests.hs+8
@@ -69,6 +69,13 @@ testFindImage =
6969 where
7070 imageFullName = testImageName <> ":latest"
7171
72+testListContainers :: IO ()
73+testListContainers =
74+ runDocker $
75+ do res <- listContainers defaultListOpts
76+ liftIO $ print res
77+ lift $ assert $ isRight res
78+
7279testBuildFromDockerfile :: IO ()
7380testBuildFromDockerfile = do
7481 cur <- getCurrentDirectory
@@ -170,6 +177,7 @@ integrationTests =
170177 [ testCase "Get docker version" testDockerVersion
171178 , testCase "Build image from Dockerfile" testBuildFromDockerfile
172179 , testCase "Find image by name" testFindImage
180+ , testCase "List containers" testListContainers
173181 , testCase "Run a dummy container and read its log" testRunAndReadLog
174182 , testCase "Try to stop a container that doesn't exist" testStopNonexisting
175183 ]