| Copyright | (C) 2024 Bellroy Pty Ltd |
|---|---|
| License | BSD-3-Clause |
| Maintainer | Bellroy Tech Team <haskell@bellroy.com> |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Test.Tasty.Golden.Extra.GoldenVsString
Description
These helpers are useful for creating golden tests for functions that produce textual output.
Synopsis
- data GoldenVsString = GoldenVsString FilePath (IO ByteString)
- goldenVsString :: TestName -> FilePath -> IO ByteString -> TestTree
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")
Constructors
| GoldenVsString FilePath (IO ByteString) |
Instances
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.