on master help sign in
PUT test + some servant orphans
commitccf402b22d4613c7b9ffe2a732b650784511f519 authorMark Wotton <mwotton@gmail.com> dateTue 4 May 2021, 13:54 (5 years ago) parente89b45f
6 files changed+32−2
roboservant.cabal+3−1 src/Roboservant/Types.hs+2 src/Roboservant/Types/Breakdown.hs+4 src/Roboservant/Types/BuildFrom.hs+4 src/Roboservant/Types/Orphans.hs+7 test/Spec.hs+12−1
roboservant.cabal+3−1
@@ -4,7 +4,7 @@ cabal-version: 1.12
44--
55-- see: https://github.com/sol/hpack
66--
7−-- hash: 596d33d4f2e29f15b48525514def52b101c9e89b6193275bd5c0a4c253de8d5c
7+-- hash: 76f10a967a70cffa900bcc3464a1fd973642332b3a86d22a19f5e3d1d8879f4d
88
99name: roboservant
1010version: 0.1.0.2
@@ -36,6 +36,7 @@ library
3636 Roboservant.Types.BuildFrom
3737 Roboservant.Types.Config
3838 Roboservant.Types.Internal
39+ Roboservant.Types.Orphans
3940 Roboservant.Types.ReifiedApi
4041 Roboservant.Types.ReifiedApi.Server
4142 other-modules:
@@ -115,6 +116,7 @@ test-suite roboservant-test
115116 Nested
116117 Post
117118 Product
119+ Put
118120 QueryParams
119121 Seeded
120122 UnsafeIO
src/Roboservant/Types.hs+2
@@ -14,6 +14,7 @@ module Roboservant.Types
1414 module Roboservant.Types.ReifiedApi.Server,
1515 module Roboservant.Types.Internal,
1616 module Roboservant.Types.Config,
17+ module Roboservant.Types.Orphans,
1718 )
1819where
1920
@@ -23,3 +24,4 @@ import Roboservant.Types.Config
2324import Roboservant.Types.Internal
2425import Roboservant.Types.ReifiedApi
2526import Roboservant.Types.ReifiedApi.Server
27+import Roboservant.Types.Orphans()
src/Roboservant/Types/Breakdown.hs+4
@@ -22,6 +22,8 @@ import qualified Data.List.NonEmpty as NEL
2222import Data.Typeable (Typeable)
2323import GHC.Generics
2424import Roboservant.Types.Internal
25+import Servant
26+import Roboservant.Types.Orphans()
2527
2628breakdown ::
2729 (Hashable x, Typeable x, Breakdown x) =>
@@ -74,3 +76,5 @@ instance (Hashable a, Typeable a, Breakdown a) => GBreakdown (K1 R a) where
7476
7577instance GBreakdown U1 where
7678 gBreakdownExtras U1 = []
79+
80+deriving via (Atom NoContent) instance Breakdown NoContent
src/Roboservant/Types/BuildFrom.hs+4
@@ -23,6 +23,8 @@ import Data.Typeable (Typeable)
2323import GHC.Generics
2424import Roboservant.Types.Internal
2525import qualified Type.Reflection as R
26+import Servant(NoContent)
27+import Roboservant.Types.Orphans()
2628
2729buildFrom :: forall x. (Hashable x, BuildFrom x, Typeable x) => Stash -> Maybe (StashValue x)
2830buildFrom = buildStash . buildFrom'
@@ -101,3 +103,5 @@ instance BuildFrom a => GBuildFrom (K1 i a) where
101103
102104instance GBuildFrom U1 where
103105 gExtras _ = [([], U1)]
106+
107+deriving via (Atom NoContent) instance BuildFrom NoContent
src/Roboservant/Types/Orphans.hsnew file+7
@@ -0,0 +1,7 @@
1+{-# OPTIONS_GHC -fno-warn-orphans #-}
2+module Roboservant.Types.Orphans where
3+
4+import Servant
5+import Data.Hashable
6+
7+instance Hashable NoContent
test/Spec.hs+12−1
@@ -21,6 +21,7 @@ import qualified Foo
2121import qualified Headers
2222import qualified Nested
2323import qualified Post
24+import qualified Put
2425import qualified Product
2526import qualified QueryParams
2627import qualified Roboservant as R
@@ -77,6 +78,12 @@ spec = do
7778 fuzzBoth @Post.Api "passes a coverage check using a posted body" Post.server R.defaultConfig {R.coverageThreshold = 0.99}
7879 (`shouldSatisfy` isNothing)
7980
81+
82+ describe "PUTted body" $ do
83+ fuzzBoth @Put.Api "passes a coverage check using a posted body" Put.server R.defaultConfig {R.coverageThreshold = 0.99}
84+ (`shouldSatisfy` isNothing)
85+
86+
8087 describe "seeded" $ do
8188 let res = Seeded.Seed 1
8289 shouldFail $ fuzzBoth @Seeded.Api "finds an error using information passed in" Seeded.server
@@ -131,9 +138,13 @@ deriving via (R.Atom Seeded.Seed) instance R.BuildFrom Seeded.Seed
131138deriving via (R.Atom Void) instance R.BuildFrom Void
132139
133140deriving via (R.Atom Post.FooPost) instance R.Breakdown Post.FooPost
134−
135141deriving via (R.Atom Post.FooPost) instance R.BuildFrom Post.FooPost
136142
143+deriving via (R.Atom Put.Foo) instance R.Breakdown Put.Foo
144+deriving via (R.Atom Put.Foo) instance R.BuildFrom Put.Foo
145+
146+
147+
137148deriving via (R.Compound Breakdown.Foo) instance R.Breakdown Breakdown.Foo
138149
139150deriving via (R.Compound Product.Foo) instance R.BuildFrom Product.Foo