diff options
author | Olli Helenius <liff@iki.fi> | 2022-04-28 16:45:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-28 15:45:54 +0200 |
commit | 13d7df0285611bcc9138339bc8ca922907ee0a61 (patch) | |
tree | fe866685ec11ddbe92733402865b14dbce25b06e /pkgs/tools/misc/dsq | |
parent | 023cd4e8931676469a524fa048084056447bd0a6 (diff) |
dsq: replace package test with upstream test script (#170591)
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/tools/misc/dsq')
-rw-r--r-- | pkgs/tools/misc/dsq/default.nix | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/pkgs/tools/misc/dsq/default.nix b/pkgs/tools/misc/dsq/default.nix index e0ecf5be6c60e..2fef722173b15 100644 --- a/pkgs/tools/misc/dsq/default.nix +++ b/pkgs/tools/misc/dsq/default.nix @@ -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; { |