Copyright | (c) Plow Technologies 2016 |
---|---|
License | BSD3 |
Maintainer | mchaver@gmail.com |
Stability | Beta |
Safe Haskell | None |
Language | Haskell2010 |
Internal module, use at your own risk.
Synopsis
- goldenADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Spec
- goldenADTSpecsWithNote :: forall a. (ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Maybe String -> Spec
- testConstructor :: forall a. (Eq a, Show a, FromJSON a, ToJSON a, ToADTArbitrary a) => Settings -> String -> String -> ConstructorArbitraryPair a -> SpecWith (Arg (IO ()))
- compareWithGolden :: forall a. (Show a, Eq a, FromJSON a, ToJSON a, ToADTArbitrary a) => RandomMismatchOption -> String -> Maybe String -> String -> ConstructorArbitraryPair a -> FilePath -> IO ()
- createGoldenFile :: forall a. (ToJSON a, ToADTArbitrary a) => Int -> ConstructorArbitraryPair a -> FilePath -> IO ()
- mkGoldenFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair a -> FilePath
- mkFaultyFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair a -> FilePath
- mkFaultyReencodedFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair a -> FilePath
- mkRandomADTSamplesForConstructor :: forall a. ToADTArbitrary a => Int -> Proxy a -> String -> Int32 -> IO (RandomSamples a)
- mkGoldenFileForType :: forall a. (ToJSON a, ToADTArbitrary a) => Int -> Proxy a -> FilePath -> IO ()
Documentation
goldenADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Spec Source #
Tests to ensure that JSON encoding has not unintentionally changed. This could be caused by the following:
- A type's instances of
ToJSON
orFromJSON
have changed. - Selectors have been edited, added or deleted.
- You have changed version of Aeson the way Aeson serialization has changed works.
If you run this function and the golden files do not exist, it will create them for each constructor. It they do exist, it will compare with golden file if it exists. Golden file encodes json format of a type. It is recommended that you put the golden files under revision control to help monitor changes.
goldenADTSpecsWithNote :: forall a. (ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Maybe String -> Spec Source #
same as goldenADTSpecs
but has the option of passing a note to the
describe
function.
testConstructor :: forall a. (Eq a, Show a, FromJSON a, ToJSON a, ToADTArbitrary a) => Settings -> String -> String -> ConstructorArbitraryPair a -> SpecWith (Arg (IO ())) Source #
test a single set of values from a constructor for a given type.
compareWithGolden :: forall a. (Show a, Eq a, FromJSON a, ToJSON a, ToADTArbitrary a) => RandomMismatchOption -> String -> Maybe String -> String -> ConstructorArbitraryPair a -> FilePath -> IO () Source #
The golden files already exist. Serialize values with the same seed from the golden files of each constructor and compare.
createGoldenFile :: forall a. (ToJSON a, ToADTArbitrary a) => Int -> ConstructorArbitraryPair a -> FilePath -> IO () Source #
The golden files do not exist. Create them for each constructor.
mkGoldenFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair a -> FilePath Source #
Create the file path for the golden file. Optionally use the module name to help avoid name collissions. Different modules can have types of the same name.
mkFaultyFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair a -> FilePath Source #
Create the file path to save results from a failed golden test. Optionally use the module name to help avoid name collisions. Different modules can have types of the same name.
mkFaultyReencodedFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair a -> FilePath Source #
Create the file path to save results from a failed fallback golden test. Optionally use the module name to help avoid name collisions. Different modules can have types of the same name.
mkRandomADTSamplesForConstructor :: forall a. ToADTArbitrary a => Int -> Proxy a -> String -> Int32 -> IO (RandomSamples a) Source #
Create a number of arbitrary instances of a particular constructor given a sample size and a random seed.
mkGoldenFileForType :: forall a. (ToJSON a, ToADTArbitrary a) => Int -> Proxy a -> FilePath -> IO () Source #
Make a Golden File for the Proxy of a type if the file does not exist.