23 lines
661 B
Haskell
23 lines
661 B
Haskell
|
|
module Nuthatch.Test.PathFixture
|
||
|
|
( ValidPath (..)
|
||
|
|
, genValidPath
|
||
|
|
) where
|
||
|
|
|
||
|
|
import Data.Text (Text)
|
||
|
|
import qualified Data.Text as T
|
||
|
|
import Hedgehog (Gen)
|
||
|
|
import qualified Hedgehog.Gen as Gen
|
||
|
|
import qualified Hedgehog.Range as Range
|
||
|
|
|
||
|
|
newtype ValidPath = ValidPath { getValidPath :: Text }
|
||
|
|
deriving stock (Show)
|
||
|
|
|
||
|
|
genValidPath :: Gen ValidPath
|
||
|
|
genValidPath = do
|
||
|
|
segments <- Gen.list (Range.linear 1 6) genSegment
|
||
|
|
pure (ValidPath (T.intercalate "/" segments))
|
||
|
|
where
|
||
|
|
genSegment =
|
||
|
|
Gen.filter (`notElem` [".", ".."]) $
|
||
|
|
Gen.text (Range.linear 1 16) $
|
||
|
|
Gen.choice [Gen.alphaNum, Gen.element ("_-. " :: String)]
|