git.iko.soy/typeable/swagger2
on master help sign in
Add test suite with test for Info object example
commit061191f08a8e54a63cdd7c5ac9f37016d429976e authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSat 7 Nov 2015, 17:25 (11 years ago) parent0d0813a
3 files changed+73
swagger2.cabal+16 test/Data/SwaggerSpec.hs+56 test/Spec.hs+1
swagger2.cabal+16
@@ -30,6 +30,22 @@ library
3030 , unordered-containers
3131 default-language: Haskell2010
3232
33+test-suite spec
34+ type: exitcode-stdio-1.0
35+ hs-source-dirs: test
36+ main-is: Spec.hs
37+ build-depends: base == 4.*
38+ , swagger2
39+ , hspec
40+ , HUnit
41+ , QuickCheck
42+ , text
43+ , aeson
44+ , aeson-qq
45+ other-modules:
46+ Data.SwaggerSpec
47+ default-language: Haskell2010
48+
3349source-repository head
3450 type: git
3551 location: https://github.com/GetShopTV/swagger2.git
test/Data/SwaggerSpec.hsnew file+56
@@ -0,0 +1,56 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE QuasiQuotes #-}
3+module Data.SwaggerSpec where
4+
5+import Data.Aeson
6+import Data.Aeson.QQ
7+import Data.Swagger
8+
9+import Test.Hspec
10+import Test.Hspec.HUnit
11+
12+infoExample :: SwaggerInfo
13+infoExample = SwaggerInfo
14+ { swaggerInfoTitle = "Swagger Sample App"
15+ , swaggerInfoDescription = Just "This is a sample server Petstore server."
16+ , swaggerInfoTermsOfService = Just "http://swagger.io/terms/"
17+ , swaggerInfoContact = Just contact
18+ , swaggerInfoLicense = Just license
19+ , swaggerInfoVersion = "1.0.1" }
20+ where
21+ contact = SwaggerContact
22+ { swaggerContactName = Just "API Support"
23+ , swaggerContactUrl = Just (URL "http://www.swagger.io/support")
24+ , swaggerContactEmail = Just "support@swagger.io" }
25+ license = SwaggerLicense
26+ { swaggerLicenseName = "Apache 2.0"
27+ , swaggerLicenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
28+
29+infoExampleJSON :: Value
30+infoExampleJSON = [aesonQQ|
31+{
32+ "title": "Swagger Sample App",
33+ "description": "This is a sample server Petstore server.",
34+ "termsOfService": "http://swagger.io/terms/",
35+ "contact": {
36+ "name": "API Support",
37+ "url": "http://www.swagger.io/support",
38+ "email": "support@swagger.io"
39+ },
40+ "license": {
41+ "name": "Apache 2.0",
42+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
43+ },
44+ "version": "1.0.1"
45+}
46+|]
47+
48+spec :: Spec
49+spec = do
50+ describe "Info Object" $ do
51+ it "encodes correctly" $ do
52+ toJSON infoExample `shouldBe` infoExampleJSON
53+
54+main :: IO ()
55+main = hspec spec
56+
test/Spec.hsnew file+1
@@ -0,0 +1 @@
1+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}