servant-routes-golden
Copyright(c) Frederick Pringle 2025
LicenseBSD-3-Clause
Maintainerfrederick.pringle@fpringle.com
Safe HaskellNone
LanguageHaskell2010

Servant.API.Routes.Golden

Description

The HasRoutes class allows us to generate a list of Routes from a Servant API type. Using "hspec-golden", we can generate automatic Golden tests from these APIs. If such a test fails, we know that the shape of our API has changed. Therefore we must either:

  • decide that the shape change is correct, and acknowledge that the golden files should be updated, by running the hgold CLI, or
  • realise that our changes resulted in a change to the API which we didn't intend/anticipate, so we have to fix them.
Synopsis

Generating golden tests using HasRoutes

goldenRoutes :: HasRoutes api => String -> Golden Value Source #

Given an API type with a HasRoutes instance, we can create a Golden test on the Routes representation of that API. This can be used to automatically track changes to the API shape during testing. For a concrete example see the README.

goldenRoutesSpec :: HasRoutes api => String -> Spec Source #

Generate a Spec for your API type.