-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golden & roundtrips on *all* Api types #116
Conversation
6b0a3aa
to
f6086b7
Compare
f6086b7
to
5aee9af
Compare
5aee9af
to
252652c
Compare
8a539ea
to
1916637
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good modulo the case for query / path parameters within Capture
.
It'd be nice one day to also get the roundtrip automagically for nested types, yet, it's not trivial 🤔
roundtripAndGoldenPerType _ = | ||
Set.union | ||
(roundtripAndGoldenPerType $ Proxy @t) | ||
(roundtripAndGoldenPerType $ Proxy @b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That one is incorrect. There's no reason for a param t
to have a a JSON instance. Instead, we should be checking for HttpApiData
roundtrips here!
@KtorZ I just discovered that
goldenADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Spec I'm checking how it works. If it is close to trivial we could add now, otherwise later. Probably in a separate pr regardless. Did not get this working at all 🤷♂️ (as in simple to set-up, but it only ran tests on the original type for some reason) |
-> TODO: Go through the servant combinators. ReqBody? No need. We'll add them as we add API types. |
Tests all Aeson instances in the Api automatically.
097efd4
to
06af835
Compare
Closing for now, the value wasn't clear enough. A few problems: Lacking reduction of test casesThe pr had logic for generating test-cases for Not testing ADT components-- We are relying heavily on generically derived Aeson instances. This is used
-- to trace the failure of @roundtripAndGolden@.
--
-- Example:
-- @
-- data Record { a :: A, b :: B, c :: C, ds :: [D] }
-- deriving (Generic, ToJSON, FromJSON)
-- @
--
-- If we hand-write faulty Aeson instances for 'D', we'd like to discover that
-- easily when checking roundtrips and goldens on 'Record'. Dangers of regenerationIf we believe we're making a purely additively change to a type, but screw something up, the tests won't help us. They are re-generated. (actually, no, but not re-generating them is also a problem) For the future
|
Issue Number
#91
Overview
roundtripAndGoldenPerType
+ machinery to run tests on allApi
Capture
- and return-types.ReqBody
?WIP machinery for taking apart ADTs and runningroundtripAndGolden
on each component.It was able to runroundtripAndGolden
for the type of each field of a recordI was unable to hook it up with theApi
discoveryI didn't figure out how to "catch" an hspec failure, such that we could then run more detailed tests on the components on the failing type (see comment forGRecursiveCheckJSON
)Comments