Merge pull request #49 from DaQuirm/fix/envvar-json-encoding

Fix EnvVar JSON encoding
This commit is contained in:
Deni Bertovic 2018-01-08 15:09:25 +01:00 committed by GitHub
commit ea7f6b0d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -1348,7 +1348,7 @@ instance FromJSON EnvVar where
parseJSON _ = fail "EnvVar is not a string"
instance ToJSON EnvVar where
toJSON (EnvVar n v) = object [n .= v]
toJSON (EnvVar n v) = JSON.String $ n <> T.pack "=" <> v
-- | ExposedPort represents a port (and it's type)
-- that a container should expose to other containers or the host system.

View File

@ -163,6 +163,15 @@ testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, test
Just (Entrypoint sampleEntrypointArr)
sampleEntrypointArr = ["cmd", "--some-flag", "--some-flag2"]
testEnvVarJson :: TestTree
testEnvVarJson = testGroup "Testing EnvVar JSON" [testSampleEncode, testSampleDecode]
where
testSampleEncode =
testCase "Test toJSON" $ assert $ JSON.toJSON (EnvVar "cellar" "door") == JSON.String "cellar=door"
testSampleDecode =
testCase "Test fromJSON" $ assert $ (JSON.decode "\"cellar=door\"" :: Maybe EnvVar) ==
Just (EnvVar "cellar" "door")
integrationTests :: TestTree
integrationTests =
testGroup
@ -183,6 +192,7 @@ jsonTests =
, testLabelsJson
, testLogDriverOptionsJson
, testEntrypointJson
, testEnvVarJson
]
setup :: IO ()