polysemy-test: Polysemy effects for testing

[ library, test ] [ Propose Tags ]
This version is deprecated.

Please see the README on Github at https://github.com/tek/polysemy-test


[Skip to Readme]

Modules

[Index] [Quick Jump]

  • Paths_polysemy_test
  • Polysemy
    • Polysemy.Test
      • Data
        • Polysemy.Test.Data.Hedgehog
        • Polysemy.Test.Data.Test
        • Polysemy.Test.Data.TestError
      • Polysemy.Test.Files
      • Polysemy.Test.Hedgehog
      • Polysemy.Test.Prelude
      • Polysemy.Test.Run

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.3.0.1, 0.3.0.2, 0.3.1.0, 0.3.1.1, 0.3.1.2, 0.3.1.3, 0.3.1.4, 0.3.1.5, 0.3.1.6, 0.3.1.7, 0.3.1.8, 0.3.1.9, 0.4.0.0, 0.4.0.1, 0.5.0.0, 0.6.0.0, 0.7.0.0, 0.8.0.0, 0.8.0.1, 0.9.0.0 (info)
Change log Changelog.md
Dependencies base (>=4 && <5), containers, either, hedgehog (>=1.0.2 && <1.1), path (>=0.8 && <0.9), path-io (>=0.3.1 && <0.4), polysemy (>=1.3.0 && <1.4), polysemy-plugin (>=0.2.5 && <0.3), relude (>=0.7 && <0.8), string-interpolate (>=0.1 && <0.4), tasty (>=1.2.3 && <1.3), tasty-hedgehog (>=1 && <1.1), text, transformers [details]
License BSD-2-Clause-Patent
Copyright 2020 Torsten Schmits
Author Torsten Schmits
Maintainer tek@tryp.io
Category Test
Uploaded by tek at 2020-09-25T18:08:10Z
Distributions
Reverse Dependencies 5 direct, 15 indirect [details]
Downloads 2860 total (63 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for polysemy-test-0.3.0.1

[back to package description]

About

This package provides utilities for testing Polysemy programs:

  • An effect, Test, that gives access to temporary files and fixtures
  • An effect, Hedgehog, for lifted Hedgehog assertions

Example

import Path (relfile)
import Polysemy.Test
import Test.Tasty (defaultMain)

test_fixture :: UnitTest
test_fixture =
  runTestAuto do
    fixContent1 <- fixtureLines fixRel
    fixPath <- Test.fixturePath fixRel
    fixContent2 <- Text.lines <$> embed (Text.readFile (toFilePath fixPath))
    fixContent1 === fixContent2
    fixContent1 === ["file", "content"]
  where
    fixRel =
      [relfile|files/file1|]

main :: IO ()
main =
  defaultMain (unitTest test_fixture)

Fixtures

Any file that is located below the subdirectory fixtures inside the test directory can be accessed using the constructors Test.fixturePath, Test.fixture and Text.fixtureLines.

You can override the path used to look for the fixtures directory by using runTest instead of runTestAuto. The latter analyzes the call stack to determine the test directory.

Temp Files

The constructors Test.tempDir, Test.tempFile, Test.tempFileContent and Test.tempFileLines allow you to create and read files in the temp directory within the test directory.

Paths

All paths are of type Path from the package path.

You can construct them using the quasiquoters reldir, absdir etc. or the functions parseRelDir, parseAbsDir etc.