nri-test-encoding-0.1.1.1: A library to simplify writing golden tests for encoding types.
Safe HaskellNone
LanguageHaskell2010

Test.Encoding.Routes

Description

Test helpers to ensure we don't change types or encodings of types used in our request and response bodies by accident. crawl will traverse our entire Routes API for request and response body types, and fail to compile if we don't provide example values for each. We can then run a golden result test for each, meaning we encode each example value to JSON and check it matches a known-good encoding we have comitted to the repo.

Synopsis

Documentation

tests :: forall routes. IsApi (ToServantApi routes) => Proxy routes -> List Test Source #

Creates tests for routes and custom types used in routes.

Example usage: describe Spec.ApiEncoding (TestEncoding.tests (Proxy :: Proxy Routes.Routes))

class IsApi a where Source #

A helper type class that provides us example values of particular types. The IsApi typeclass below will demand we define an instance of this type class for each type used in a request or response body.

A helper type class that can crawl our servant Routes type and return us JSON-encoded examples for each request and response body type in that API. Example usage:

routes = crawl (Proxy :: Proxy (ToServantApi Routes.Routes))

Methods

crawl :: Proxy a -> [Route] Source #

Instances

Instances details
IsApi Raw Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy Raw -> [Route] Source #

(IsApi a, IsApi b) => IsApi (a :<|> b :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (a :<|> b) -> [Route] Source #

(Typeable body, HasExamples body, IsApi a) => IsApi (ReqBody' x encodings body :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (ReqBody' x encodings body :> a) -> [Route] Source #

IsApi a => IsApi (QueryFlag flag :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (QueryFlag flag :> a) -> [Route] Source #

(KnownSymbol key, Typeable val, HasExamples val, IsApi a) => IsApi (Header key val :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (Header key val :> a) -> [Route] Source #

IsApi a => IsApi (Summary x :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (Summary x :> a) -> [Route] Source #

(KnownSymbol s, IsApi a) => IsApi (Capture' mods s paramType :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (Capture' mods s paramType :> a) -> [Route] Source #

IsApi a => IsApi (Auth types user :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (Auth types user :> a) -> [Route] Source #

(KnownSymbol s, IsApi a) => IsApi (s :> a :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (s :> a) -> [Route] Source #

(Typeable method, Typeable body, HasExamples body) => IsApi (Verb method status encodings body :: Type) Source # 
Instance details

Defined in Test.Encoding.Routes

Methods

crawl :: Proxy (Verb method status encodings body) -> [Route] Source #

Orphan instances