git.iko.soy/typeable/openapi3
on master help sign in
Use only strict JSON check in tests
commite07b4027c62b326b838c225b3ebe62045f9a2ab4 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSat 12 Dec 2015, 14:04 (11 years ago) parentf18f8b2
3 files changed+11−18
test/Data/Swagger/SchemaSpec.hs+1−1 test/Data/SwaggerSpec.hs+10−10 test/SpecCommon.hs−7
test/Data/Swagger/SchemaSpec.hs+1−1
@@ -23,7 +23,7 @@ import SpecCommon
2323import Test.Hspec
2424
2525checkToSchema :: ToSchema a => Proxy a -> Value -> Spec
26−checkToSchema proxy js = toSchema proxy <~> js
26+checkToSchema proxy js = toSchema proxy <=> js
2727
2828checkSchemaName :: ToSchema a => Maybe String -> Proxy a -> Spec
2929checkSchemaName sname proxy =
test/Data/SwaggerSpec.hs+10−10
@@ -21,18 +21,18 @@ spec = do
2121 describe "License Object" $ licenseExample <=> licenseExampleJSON
2222 describe "Contact Object" $ contactExample <=> contactExampleJSON
2323 describe "Info Object" $ infoExample <=> infoExampleJSON
24− describe "Operation Object" $ operationExample <~> operationExampleJSON
24+ describe "Operation Object" $ operationExample <=> operationExampleJSON
2525 describe "Schema Object" $ do
26− context "Primitive Sample" $ schemaPrimitiveExample <~> schemaPrimitiveExampleJSON
27− context "Simple Model" $ schemaSimpleModelExample <~> schemaSimpleModelExampleJSON
28− context "Model with Map/Dictionary Properties" $ schemaModelDictExample <~> schemaModelDictExampleJSON
29− context "Model with Example" $ schemaWithExampleExample <~> schemaWithExampleExampleJSON
30− describe "Definitions Object" $ definitionsExample <~> definitionsExampleJSON
31− describe "Parameters Definition Object" $ paramsDefinitionExample <~> paramsDefinitionExampleJSON
32− describe "Responses Definition Object" $ responsesDefinitionExample <~> responsesDefinitionExampleJSON
33− describe "Security Definitions Object" $ securityDefinitionsExample <~> securityDefinitionsExampleJSON
26+ context "Primitive Sample" $ schemaPrimitiveExample <=> schemaPrimitiveExampleJSON
27+ context "Simple Model" $ schemaSimpleModelExample <=> schemaSimpleModelExampleJSON
28+ context "Model with Map/Dictionary Properties" $ schemaModelDictExample <=> schemaModelDictExampleJSON
29+ context "Model with Example" $ schemaWithExampleExample <=> schemaWithExampleExampleJSON
30+ describe "Definitions Object" $ definitionsExample <=> definitionsExampleJSON
31+ describe "Parameters Definition Object" $ paramsDefinitionExample <=> paramsDefinitionExampleJSON
32+ describe "Responses Definition Object" $ responsesDefinitionExample <=> responsesDefinitionExampleJSON
33+ describe "Security Definitions Object" $ securityDefinitionsExample <=> securityDefinitionsExampleJSON
3434 describe "Swagger Object" $ do
35− context "Todo Example" $ swaggerExample <~> swaggerExampleJSON
35+ context "Todo Example" $ swaggerExample <=> swaggerExampleJSON
3636 context "PetStore Example" $
3737 it "decodes successfully" $ do
3838 fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: Swagger) -> True; _ -> False)
test/SpecCommon.hs−7
@@ -15,13 +15,6 @@ isSubJSON (Object x) (Object y) = HashMap.keys x == HashMap.keys i && F.and i
1515isSubJSON (Array xs) (Array ys) = Vector.length xs == Vector.length ys && F.and (Vector.zipWith isSubJSON xs ys)
1616isSubJSON x y = x == y
1717
18−(<~>) :: (Eq a, Show a, ToJSON a, FromJSON a) => a -> Value -> Spec
19−x <~> js = do
20− it "encodes correctly (probably with extra properties)" $ do
21− toJSON x `shouldSatisfy` (js `isSubJSON`)
22− it "decodes correctly" $ do
23− fromJSON js `shouldBe` Success x
24−
2518(<=>) :: (Eq a, Show a, ToJSON a, FromJSON a) => a -> Value -> Spec
2619x <=> js = do
2720 it "encodes correctly" $ do