mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-19 22:07:13 +03:00
Test the case hack against a NAR fixture with case conflicts
This commit is contained in:
parent
0092a2952f
commit
c68762f8d7
@ -5,6 +5,7 @@ module NarFormat where
|
||||
|
||||
import qualified Control.Concurrent as Concurrent
|
||||
import Control.Exception (try)
|
||||
import Data.Binary (Binary(..), decodeFile)
|
||||
import Data.Binary.Get (Get, getByteString,
|
||||
getInt64le,
|
||||
getLazyByteString, runGet)
|
||||
@ -100,6 +101,10 @@ spec_narEncoding = do
|
||||
it "roundtrips directory" $ do
|
||||
roundTrip "sampleDirectory" (Nar sampleDirectory)
|
||||
|
||||
it "roundtrips case conflicts" $ do
|
||||
nar <- decodeFile "tests/fixtures/case-conflict.nar"
|
||||
roundTrip "caseConflict" nar
|
||||
|
||||
describe "matches-nix-store fixture" $ do
|
||||
it "matches regular" $ do
|
||||
encEqualsNixStore (Nar sampleRegular) sampleRegularBaseline
|
||||
@ -115,6 +120,7 @@ spec_narEncoding = do
|
||||
|
||||
it "matches directory" $ do
|
||||
encEqualsNixStore (Nar sampleDirectory) sampleDirectoryBaseline
|
||||
|
||||
it "matches symlink to directory" $ do
|
||||
encEqualsNixStore (Nar sampleLinkToDirectory) sampleLinkToDirectoryBaseline
|
||||
|
||||
@ -578,7 +584,7 @@ filePathPart :: BSC.ByteString -> Maybe FilePathPart
|
||||
filePathPart p = if BSC.any (`elem` ['/', '\NUL']) p then Nothing else Just $ FilePathPart p
|
||||
|
||||
newtype Nar = Nar { narFile :: FileSystemObject }
|
||||
deriving (Eq, Show)
|
||||
deriving (Eq, Show, Generic)
|
||||
|
||||
-- | A FileSystemObject (FSO) is an anonymous entity that can be NAR archived
|
||||
data FileSystemObject =
|
||||
@ -594,6 +600,9 @@ data FileSystemObject =
|
||||
newtype FilePathPart = FilePathPart { unFilePathPart :: BSC.ByteString }
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
instance Binary Nar where
|
||||
get = getNar
|
||||
put = putNar
|
||||
|
||||
instance Arbitrary Nar where
|
||||
arbitrary = Nar <$> resize 10 arbitrary
|
||||
|
3
hnix-store-core/tests/fixtures/.gitignore
vendored
Normal file
3
hnix-store-core/tests/fixtures/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*
|
||||
!*.nar
|
||||
!*.*
|
BIN
hnix-store-core/tests/fixtures/case-conflict.nar
vendored
Normal file
BIN
hnix-store-core/tests/fixtures/case-conflict.nar
vendored
Normal file
Binary file not shown.
8
hnix-store-core/tests/fixtures/generate-fixtures.sh
vendored
Executable file
8
hnix-store-core/tests/fixtures/generate-fixtures.sh
vendored
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Generate a NAR file with case conflicts in the file names.
|
||||
mkdir -p case-conflict/bar
|
||||
touch case-conflict/{Foo.txt,foo.txt,Baz.txt,bar/baz.txt}
|
||||
|
||||
storePath=$(nix-store --add ./case-conflict)
|
||||
nix-store --dump $storePath > case-conflict.nar
|
Loading…
Reference in New Issue
Block a user