config/pkgs/compress-drv/test.nix

28 lines
559 B
Nix
Raw Normal View History

2024-02-24 19:43:19 +02:00
{
gzip,
2024-07-06 22:45:14 +03:00
runCommand,
compressDrv,
2024-02-24 19:43:19 +02:00
}: let
2024-07-06 22:45:14 +03:00
example = runCommand "sample-drv" {} ''
2024-02-24 19:43:19 +02:00
mkdir $out
2024-07-06 22:45:14 +03:00
echo 42 > $out/1.txt
2024-02-24 19:43:19 +02:00
touch $out/2.png
'';
drv = compressDrv example {
formats = ["txt"];
compressors = ["gz"];
compressor-gz = "${gzip}/bin/gzip --force --keep --fast {}";
};
in
2024-07-06 22:45:14 +03:00
runCommand "test-compressDrv" {} ''
2024-02-24 19:43:19 +02:00
set -ex
find ${drv}
test -h ${drv}/1.txt
test -f ${drv}/1.txt.gz
cmp ${drv}/1.txt <(${gzip}/bin/zcat ${drv}/1.txt.gz)
test -h ${drv}/2.png
test ! -a ${drv}/2.png.gz
mkdir $out
''