Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
Nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166let lib = import ./..;
inherit (lib) fakeHash fakeSha256 fakeSha512 flip functionArgs runTests ; inherit (lib.fetchers) normalizeHash withNormalizedHash;
testingThrow = expr: { expr = with builtins; tryEval (seq expr "didn't throw"); expected = { success = false; value = false; }; };
# hashes of empty sri256 = "sha256-d6xi4mKdjkX2JFicDIv5niSzpyI0m/Hnm8GGAIU04kY="; sri512 = "sha512-AXFyVo7jiZ5we10fxZ5E9qfPjSfqkizY2apCzORKFVYZaNhCIVbooY+J4cYST00ztLf0EjivIBPPdtIYFUMfzQ==";
unionOfDisjoints = lib.foldl lib.attrsets.unionOfDisjoint { };
genTests = n: f: { "test${n}AlreadyNormalized" = { expr = f { } { outputHash = ""; outputHashAlgo = "md42"; }; expected = { outputHash = ""; outputHashAlgo = "md42"; }; };
"test${n}EmptySha256" = { expr = f { } { sha256 = ""; }; expected = { outputHash = fakeSha256; outputHashAlgo = "sha256"; }; };
"test${n}EmptySha512" = { expr = f { hashTypes = [ "sha512" ]; } { sha512 = ""; }; expected = { outputHash = fakeSha512; outputHashAlgo = "sha512"; }; };
"test${n}EmptyHash" = { expr = f { } { hash = ""; }; expected = { outputHash = fakeHash; outputHashAlgo = null; }; };
"test${n}Sri256" = { expr = f { } { hash = sri256; }; expected = { outputHash = sri256; outputHashAlgo = null; }; };
"test${n}Sri512" = { expr = f { } { hash = sri512; }; expected = { outputHash = sri512; outputHashAlgo = null; }; };
"test${n}PreservesAttrs" = { expr = f { } { hash = "aaaa"; destination = "Earth"; }; expected = { outputHash = "aaaa"; outputHashAlgo = null; destination = "Earth"; }; };
"test${n}RejectsSha1ByDefault" = testingThrow (f { } { sha1 = ""; }); "test${n}RejectsSha512ByDefault" = testingThrow (f { } { sha512 = ""; });
"test${n}ThrowsOnMissing" = testingThrow (f { } { gibi = false; }); };inrunTests (unionOfDisjoints [ (genTests "NormalizeHash" normalizeHash) (genTests "WithNormalized" ( flip withNormalizedHash ({ outputHash, outputHashAlgo, ... }@args: args) )) { testNormalizeNotRequiredEquivalent = { expr = normalizeHash { required = false; } { hash = ""; prof = "shadoko"; }; expected = normalizeHash { } { hash = ""; prof = "shadoko"; }; };
testNormalizeNotRequiredPassthru = { expr = normalizeHash { required = false; } { "ga bu" = "zo meu"; }; expected."ga bu" = "zo meu"; };
testOptionalArg = { expr = withNormalizedHash { } ( { outputHash ? "", outputHashAlgo ? null, ... }@args: args ) { author = "Jacques Rouxel"; }; expected.author = "Jacques Rouxel"; };
testOptionalArgMetadata = { expr = functionArgs ( withNormalizedHash { } ( { outputHash ? "", outputHashAlgo ? null, }: { } ) ); expected.hash = true; };
testPreservesArgsMetadata = { expr = functionArgs ( withNormalizedHash { } ( { outputHash, outputHashAlgo, pumping ? true, }: { } ) ); expected = { hash = false; pumping = true; }; };
testRejectsMissingHashArg = testingThrow (withNormalizedHash { } ({ outputHashAlgo }: { })); testRejectsMissingAlgoArg = testingThrow (withNormalizedHash { } ({ outputHash }: { })); }])