Golden tests parameters
import Data.Text (Text)
import qualified Data.Text.IO as T
goldenText :: String -> Text -> Golden Text
goldenText name actualOutput =
Golden {
output = actualOutput,
encodePretty = prettyText,
writeToFile = T.writeFile,
readFromFile = T.readFile,
goldenFile = ".specific-golden-dir" / name / "golden",
actualFile = Just (".specific-golden-dir" / name / "actual"),
failFirstTime = False
}
describe "myTextFunc" $
it "generates the right output with the right params" $
goldenText "myTextFunc" (myTextFunc params)
Constructors
Goldenoutput :: strOutput
encodePretty :: str -> StringMakes the comparison pretty when the test fails
writeToFile :: FilePath -> str -> IO ()How to write into the golden file the file
readFromFile :: FilePath -> IO strHow to read the file,
goldenFile :: FilePathWhere to read/write the golden file for this test.
actualFile :: Maybe FilePathWhere to save the actual file for this test. If it is
Nothingthen no file is written.failFirstTime :: BoolWhether to record a failure the first time this test is run
Instances8Example, Arg, …
Eq str => Example (IO (Golden str))Defined in hspec-golden-0.2.2.0 · Test.Hspec.GoldenEq str => Example (Golden str)Defined in hspec-golden-0.2.2.0 · Test.Hspec.GoldenEq str => Example (arg -> IO (Golden str))Defined in hspec-golden-0.2.2.0 · Test.Hspec.GoldenEq str => Example (arg -> Golden str)Defined in hspec-golden-0.2.2.0 · Test.Hspec.Goldentype Arg (IO (Golden str)) = ()Defined in hspec-golden-0.2.2.0 · Test.Hspec.Goldentype Arg (Golden str) = ()Defined in hspec-golden-0.2.2.0 · Test.Hspec.Goldentype Arg (arg -> IO (Golden str)) = argDefined in hspec-golden-0.2.2.0 · Test.Hspec.Goldentype Arg (arg -> Golden str) = argDefined in hspec-golden-0.2.2.0 · Test.Hspec.Golden