dsq: replace package test with upstream test script (#170591)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
Olli Helenius 2022-04-28 16:45:54 +03:00 committed by GitHub
parent 023cd4e893
commit 13d7df0285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,9 +4,12 @@
, buildGoModule
, runCommand
, nix-update-script
, dsq
, fetchurl
, testers
, diffutils
, python3
, curl
, jq
, dsq
}:
buildGoModule rec {
@ -22,35 +25,36 @@ buildGoModule rec {
vendorSha256 = "sha256-yfhLQBmWkG0ZLjI/ArLZkEGvClmZXkl0o7fEu5JqHM8=";
nativeBuildInputs = [ diffutils ];
ldflags = [ "-X" "main.Version=${version}" ];
checkInputs = [ python3 curl jq ];
preCheck =
let
taxiCsv = fetchurl {
url = "https://s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2021-04.csv";
hash = "sha256-CXJPraOYAy5tViDcBi9gxI/rJ3ZXqOa/nJ/d+aREV+M=";
};
in
''
substituteInPlace scripts/test.py \
--replace '${taxiCsv.url}' file://${taxiCsv} \
--replace 'dsq latest' 'dsq ${version}'
'';
checkPhase = ''
runHook preCheck
cp "$GOPATH/bin/dsq" .
python3 scripts/test.py
runHook postCheck
'';
passthru = {
updateScript = nix-update-script { attrPath = pname; };
tests = {
version = testers.testVersion { package = dsq; };
pretty-csv = runCommand "${pname}-test" { } ''
mkdir "$out"
cat <<EOF > "$out/input.csv"
first,second
1,a
2,b
EOF
cat <<EOF > "$out/expected.txt"
+-------+--------+
| first | second |
+-------+--------+
| 1 | a |
| 2 | b |
+-------+--------+
EOF
${dsq}/bin/dsq --pretty "$out/input.csv" 'select first, second from {}' > "$out/actual.txt"
diff "$out/expected.txt" "$out/actual.txt"
'';
};
tests.version = testers.testVersion { package = dsq; };
};
meta = with lib; {