This repository was archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests.nix
58 lines (54 loc) · 1.45 KB
/
tests.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ pkgs ? (let flake = builtins.getFlake (builtins.toString ./.); in flake.inputs.nixpkgs.legacyPackages.${builtins.currentSystem})
, lib ? pkgs.lib
, testFunc ? lib.debug.runTests
}:
let
inherit (import ./default.nix { inherit pkgs lib; }) fetchModule;
fixture = lib.importJSON ./fixtures/kitchen_sink/package-lock.json;
getModule = mod: fixture.packages.${mod};
npmRoot = ./fixtures/kitchen_sink;
inherit (builtins) typeOf baseNameOf;
in
testFunc {
testFetchHttp = {
expr =
let
src = fetchModule {
module = getModule "node_modules/accepts";
};
in
{
inherit (src) url outputHash;
};
expected = {
outputHash = "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==";
url = "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz";
};
};
testFetchGit = {
expr =
let
src = fetchModule {
module = getModule "node_modules/node-fetch";
};
in
{
inherit (src) rev submodules;
};
expected = {
rev = "8b3320d2a7c07bce4afc6b2bf6c3bbddda85b01f";
submodules = false;
};
};
testFetchPath = {
expr =
let
src = fetchModule {
module = getModule "node_modules/trivial";
inherit npmRoot;
};
in
{ type = typeOf src.outPath; base = baseNameOf src.outPath; };
expected = { type = "path"; base = "trivial"; };
};
}