test(tvix/glue): add tests for fetchurl and fetchTarball

Change-Id: I53a0590ecf4e5fcb1bfd1d127824211338e28256
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11503
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
Florian Klink 2024-04-22 16:51:16 +03:00 committed by flokli
parent 30950833c9
commit dfef3d18d1
4 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1 @@
[ /nix/store/7adgvk5zdfq4pwrhsm3n9lzypb12gw0g-source /nix/store/7adgvk5zdfq4pwrhsm3n9lzypb12gw0g-source /nix/store/7adgvk5zdfq4pwrhsm3n9lzypb12gw0g-source /nix/store/7adgvk5zdfq4pwrhsm3n9lzypb12gw0g-source /nix/store/7adgvk5zdfq4pwrhsm3n9lzypb12gw0g-source /nix/store/md9dsn2zwa6aj7zzalvjwwwx82whcyva-some-name ]

View file

@ -0,0 +1,42 @@
[
# (fetchTarball "url") cannot be tested, as that one has to fetch from the
# internet to calculate the path.
# with url and sha256
(builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/91050ea1e57e50388fa87a3302ba12d188ef723a.tar.gz";
sha256 = "1hf6cgaci1n186kkkjq106ryf8mmlq9vnwgfwh625wa8hfgdn4dm";
})
# with url and sha256 (as SRI)
(builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/91050ea1e57e50388fa87a3302ba12d188ef723a.tar.gz";
sha256 = "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=";
})
# with another url, it actually doesn't matter (no .gz prefix)
(builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/91050ea1e57e50388fa87a3302ba12d188ef723a.tar";
sha256 = "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=";
})
# also with an entirely different url, it doesn't change
(builtins.fetchTarball {
url = "https://test.example/owo";
sha256 = "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=";
})
# … because `name` defaults to source, and that (and the sha256 affect the store path)
(builtins.fetchTarball {
name = "source";
url = "https://test.example/owo";
sha256 = "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=";
})
# … so changing name causes the hash to change.
(builtins.fetchTarball {
name = "some-name";
url = "https://test.example/owo";
sha256 = "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=";
})
]

View file

@ -0,0 +1 @@
[ /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch ]

View file

@ -0,0 +1,23 @@
[
# (fetchurl "url") cannot be tested, as that one has to fetch from the
# internet to calculate the path.
# fetchurl with url and sha256
(builtins.fetchurl {
url = "https://raw.githubusercontent.com/aaptel/notmuch-extract-patch/f732a53e12a7c91a06755ebfab2007adc9b3063b/notmuch-extract-patch";
sha256 = "0nawkl04sj7psw6ikzay7kydj3dhd0fkwghcsf5rzaw4bmp4kbax";
})
# fetchurl with url and sha256 (as SRI)
(builtins.fetchurl {
url = "https://raw.githubusercontent.com/aaptel/notmuch-extract-patch/f732a53e12a7c91a06755ebfab2007adc9b3063b/notmuch-extract-patch";
sha256 = "sha256-Xa1Jbl2Eq5+L0ww+Ph1osA3Z/Dxe/RkN1/dITQCdXFk=";
})
# fetchurl with another url, but same name
(builtins.fetchurl {
url = "https://test.example/owo";
name = "notmuch-extract-patch";
sha256 = "sha256-Xa1Jbl2Eq5+L0ww+Ph1osA3Z/Dxe/RkN1/dITQCdXFk=";
})
]