on master help sign in
Merge branch 'master' of https://github.com/denibertovic/docker-hs
75d2c53James Parker
src/Docker/Client/Types.hs+1−1
@@ -1348,7 +1348,7 @@ instance FromJSON EnvVar where
1348 parseJSON _ = fail "EnvVar is not a string"
1348 parseJSON _ = fail "EnvVar is not a string"
1349
1349
1350instance ToJSON EnvVar where
1350instance ToJSON EnvVar where
1351− toJSON (EnvVar n v) = object [n .= v]
1351+ toJSON (EnvVar n v) = JSON.String $ n <> T.pack "=" <> v
1352
1352
1353-- | ExposedPort represents a port (and it's type)
1353-- | ExposedPort represents a port (and it's type)
1354-- that a container should expose to other containers or the host system.
1354-- that a container should expose to other containers or the host system.
tests/tests.hs+10
@@ -164,6 +164,15 @@ testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, test
164 Just (Entrypoint sampleEntrypointArr)
164 Just (Entrypoint sampleEntrypointArr)
165 sampleEntrypointArr = ["cmd", "--some-flag", "--some-flag2"]
165 sampleEntrypointArr = ["cmd", "--some-flag", "--some-flag2"]
166
166
167+testEnvVarJson :: TestTree
168+testEnvVarJson = testGroup "Testing EnvVar JSON" [testSampleEncode, testSampleDecode]
169+ where
170+ testSampleEncode =
171+ testCase "Test toJSON" $ assert $ JSON.toJSON (EnvVar "cellar" "door") == JSON.String "cellar=door"
172+ testSampleDecode =
173+ testCase "Test fromJSON" $ assert $ (JSON.decode "\"cellar=door\"" :: Maybe EnvVar) ==
174+ Just (EnvVar "cellar" "door")
175+
167integrationTests :: TestTree
176integrationTests :: TestTree
168integrationTests =
177integrationTests =
169 testGroup
178 testGroup
@@ -184,6 +193,7 @@ jsonTests =
184 , testLabelsJson
193 , testLabelsJson
185 , testLogDriverOptionsJson
194 , testLogDriverOptionsJson
186 , testEntrypointJson
195 , testEntrypointJson
196+ , testEnvVarJson
187 ]
197 ]
188
198
189setup :: IO ()
199setup :: IO ()