fetchPypiLegacy: add test
This commit is contained in:
parent
d52b3a7cc0
commit
81d43b9b83
3 changed files with 16 additions and 5 deletions
|
@ -14,6 +14,8 @@
|
|||
file,
|
||||
# SRI hash
|
||||
hash,
|
||||
# allow overriding the derivation name
|
||||
name ? null,
|
||||
}:
|
||||
let
|
||||
urls' = urls ++ lib.optional (url != null) url;
|
||||
|
@ -27,17 +29,16 @@ let
|
|||
in
|
||||
# Assert that we have at least one URL
|
||||
assert urls' != [ ]; runCommand file
|
||||
{
|
||||
({
|
||||
nativeBuildInputs = [ python3 ];
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||
outputHashMode = "flat";
|
||||
outputHashAlgo = null;
|
||||
# if hash is empty select a default algo to let nix propose the actual hash.
|
||||
outputHashAlgo = if hash == "" then "sha256" else null;
|
||||
outputHash = hash;
|
||||
NETRC = netrc_file;
|
||||
passthru = {
|
||||
urls = urls';
|
||||
};
|
||||
}
|
||||
// (lib.optionalAttrs (name != null) {inherit name;}))
|
||||
''
|
||||
python ${./fetch-legacy.py} ${lib.concatStringsSep " " (map (url: "--url ${lib.escapeShellArg url}") urls')} --pname ${pname} --filename ${file}
|
||||
mv ${file} $out
|
||||
|
|
9
pkgs/build-support/fetchpypilegacy/tests.nix
Normal file
9
pkgs/build-support/fetchpypilegacy/tests.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ testers, fetchPypiLegacy, ... }: {
|
||||
# Tests that we can send custom headers with spaces in them
|
||||
fetchSimple = testers.invalidateFetcherByDrvHash fetchPypiLegacy {
|
||||
pname = "requests";
|
||||
file = "requests-2.31.0.tar.gz";
|
||||
url = "https://pypi.org/simple";
|
||||
hash = "sha256-lCxadY+Y15Dq7Ropy27vx/+w0c968Fw9J5Flbb1q0eE=";
|
||||
};
|
||||
}
|
|
@ -111,6 +111,7 @@ with pkgs;
|
|||
fetchzip = callPackages ../build-support/fetchzip/tests.nix { };
|
||||
fetchgit = callPackages ../build-support/fetchgit/tests.nix { };
|
||||
fetchFirefoxAddon = callPackages ../build-support/fetchfirefoxaddon/tests.nix { };
|
||||
fetchPypiLegacy = callPackages ../build-support/fetchpypilegacy/tests.nix { };
|
||||
|
||||
install-shell-files = callPackage ./install-shell-files {};
|
||||
|
||||
|
|
Loading…
Reference in a new issue