on master help sign in
Merge branch 'master' of https://github.com/denibertovic/docker-hs
commit75d2c5349dac72c1c2104dd4f060a109a3353a9b authorJames Parker <dev@jamesparker.me> dateMon 8 Jan 2018, 16:54 (9 years ago) parent1506b2dea7f6b0
2 files changed+11−1
src/Docker/Client/Types.hs+1−1 tests/tests.hs+10
src/Docker/Client/Types.hs+1−1
@@ -1348,7 +1348,7 @@ instance FromJSON EnvVar where
13481348 parseJSON _ = fail "EnvVar is not a string"
13491349
13501350instance ToJSON EnvVar where
1351− toJSON (EnvVar n v) = object [n .= v]
1351+ toJSON (EnvVar n v) = JSON.String $ n <> T.pack "=" <> v
13521352
13531353-- | ExposedPort represents a port (and it's type)
13541354-- 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
164164 Just (Entrypoint sampleEntrypointArr)
165165 sampleEntrypointArr = ["cmd", "--some-flag", "--some-flag2"]
166166
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+
167176integrationTests :: TestTree
168177integrationTests =
169178 testGroup
@@ -184,6 +193,7 @@ jsonTests =
184193 , testLabelsJson
185194 , testLogDriverOptionsJson
186195 , testEntrypointJson
196+ , testEnvVarJson
187197 ]
188198
189199setup :: IO ()