Add fuzz test

This commit is contained in:
Jeroen Engels 2024-04-07 19:27:48 +02:00
parent 2a0cc68767
commit a9eef34293
2 changed files with 35 additions and 3 deletions

View File

@ -1,4 +1,4 @@
module Review.FilePattern exposing (FilePattern, compact, exclude, excludeFolder, include, match)
module Review.FilePattern exposing (FilePattern, compact, exclude, excludeFolder, include, match, toStrings)
import Glob exposing (Glob)
@ -44,6 +44,11 @@ compact filePatterns =
}
toStrings : Summary -> List { string : String, included : Bool }
toStrings summary =
[]
type AccumulatorType
= IncludeAcc
| ExcludeAcc

View File

@ -1,14 +1,16 @@
module Review.FilePatternTest exposing (all)
import Expect
import Review.FilePattern as FilePattern exposing (FilePattern)
import Test exposing (Test, describe, test)
import Fuzz
import Review.FilePattern as FilePattern exposing (FilePattern, include)
import Test exposing (Test, describe, fuzz, test)
all : Test
all =
describe "Review.FilePattern"
[ matchTest
, toStringsTest
]
@ -90,3 +92,28 @@ matchAgainst filePatterns str =
Err globs ->
Debug.todo ("Invalid globs:\n" ++ String.join "\n" globs)
toStringsTest : Test
toStringsTest =
fuzz (Fuzz.list (Fuzz.map2 Tuple.pair Fuzz.string Fuzz.bool)) "toStrings" <|
\list ->
case
list
|> List.map
(\( str, included ) ->
if included then
FilePattern.include str
else
FilePattern.exclude str
)
|> FilePattern.compact
of
Ok patterns ->
patterns
|> FilePattern.toStrings
|> Expect.equal []
Err _ ->
Expect.pass