Add failing test for case folding issue

This commit is contained in:
Janus Troelsen 2023-06-25 18:00:45 +02:00
parent 19de58f2ab
commit 4d28255e8e
3 changed files with 41 additions and 0 deletions

View File

@ -159,3 +159,12 @@ benchmarks:
- casa-client
ghc-options:
- -O2
tests:
unit-tests:
main: main.hs
source-dirs: unit-tests
dependencies:
- stackage-server
- hspec
- pantry

View File

@ -5,6 +5,10 @@ extra-deps:
- classy-prelude-yesod-1.5.0
- unliftio-core-0.1.2.0
- yesod-gitrepo-0.3.0
- hspec-2.11.1
- hspec-core-2.11.1
- hspec-discover-2.11.1
- hspec-expectations-0.8.3
drop-packages:
- Cabal

28
unit-tests/main.hs Normal file
View File

@ -0,0 +1,28 @@
import Pantry (parseVersionThrowing, parsePackageNameThrowing)
import Pantry.Internal.Stackage (VersionP(VersionP), PackageNameP(PackageNameP))
import Stackage.Snapshot.Diff (SnapshotDiff, snapshotDiff, toDiffList)
import Test.Hspec (Spec, describe, hspec, it, shouldBe)
snapshotDiffLength :: SnapshotDiff -> Int
snapshotDiffLength = length . toDiffList
main :: IO ()
main = do
booleanName <- PackageNameP <$> parsePackageNameThrowing "Boolean"
booleanVer <- VersionP <$> parseVersionThrowing "0.2.4"
bookkeepingName <- PackageNameP <$> parsePackageNameThrowing "bookkeeping"
bookkeepingVer <- VersionP <$> parseVersionThrowing "0.4.0.1"
let
boolean = (booleanName, booleanVer)
bookkeeping = (bookkeepingName, bookkeepingVer)
hspec $
describe "Packages with upper case characters" $
describe "Removal of bookkeeping package is one change" $ do
it "[Boolean, bookkeeping] -> [Boolean]" $
snapshotDiffLength (snapshotDiff [boolean, bookkeeping] [boolean]) `shouldBe` 1
it "[bookkeeping, Boolean] -> [Boolean]" $
snapshotDiffLength (snapshotDiff [bookkeeping, boolean] [boolean]) `shouldBe` 1