tasty-golden-extra-0.1.0.0: Additional golden test helpers for the tasty-golden package
Copyright(C) 2024 Bellroy Pty Ltd
LicenseBSD-3-Clause
MaintainerBellroy Tech Team <haskell@bellroy.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Tasty.Golden.Extra.GoldenVsString

Description

These helpers are useful for creating golden tests for functions that produce textual output.

Synopsis

Documentation

data GoldenVsString Source #

Tasty-discoverable type for creating golden tests for functions that produce textual output.

Example use:

 import MySchemasWithShowAndToJSONInstances.Person (convertToCSVText)
 import qualified Data.Aeson as Aeson
 import System.FilePath ((</>))
 import Test.Tasty.Golden.Extra.GoldenVsString (GoldenVsString (..))

 tasty_FromJSON_ToJSON :: GoldenVsString
 tasty_FromJSON_ToJSON =
   GoldenVsString (goldenFilesPath </> "Person.golden.csv") $
     maybe Error convertToCSVText $
       Aeson.decodeFileStrict' (goldenFilesPath </> "Person.json")

Instances

Instances details
Tasty GoldenVsString Source # 
Instance details

Defined in Test.Tasty.Golden.Extra.GoldenVsString

goldenVsString #

Arguments

:: TestName

test name

-> FilePath

path to the «golden» file (the file that contains correct output)

-> IO ByteString

action that returns a string

-> TestTree

the test verifies that the returned string is the same as the golden file contents

Compare a given string against the golden file's contents.