Skip to content

Commit 6575daf

Browse files
committed
test: add a test for packages with subpackages
1 parent cdd631d commit 6575daf

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

tests/test_subpackage.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import subprocess
2+
3+
import conftest
4+
5+
from nix_update.options import Options
6+
from nix_update.update import update
7+
8+
9+
def test_update(helpers: conftest.Helpers) -> None:
10+
with helpers.testpkgs() as path:
11+
opts = Options(
12+
attribute="subpackage", subpackages=["autobrr-web"], import_path=str(path)
13+
)
14+
update(opts)
15+
16+
def get_attr(attr: str) -> str:
17+
return subprocess.run(
18+
[
19+
"nix",
20+
"eval",
21+
"--raw",
22+
"--extra-experimental-features",
23+
"nix-command",
24+
"-f",
25+
path,
26+
attr,
27+
],
28+
text=True,
29+
stdout=subprocess.PIPE,
30+
).stdout.strip()
31+
32+
subpackage_hash = get_attr("subpackage.autobrr-web.pnpmDeps.outputHash")
33+
assert subpackage_hash != "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
34+
35+
src_hash = get_attr("subpackage.src.outputHash")
36+
assert src_hash != "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
37+
38+
gomodules_hash = get_attr("subpackage.goModules.outputHash")
39+
assert gomodules_hash != "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
40+
41+
version = get_attr("subpackage.version")
42+
assert tuple(map(int, version.split("."))) >= (1, 53, 0)

tests/testpkgs/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
mix = pkgs.callPackage ./mix.nix { };
3333
set = pkgs.callPackage ./set.nix { };
3434
let-bound-version = pkgs.callPackage ./let-bound-version.nix { };
35+
subpackage = pkgs.callPackage ./subpackage.nix { };
3536
}

tests/testpkgs/subpackage.nix

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
buildGoModule,
3+
fetchFromGitHub,
4+
stdenvNoCC,
5+
nodejs,
6+
pnpm_9,
7+
typescript,
8+
}:
9+
10+
let
11+
pname = "autobrr";
12+
version = "1.53.0";
13+
src = fetchFromGitHub {
14+
owner = "autobrr";
15+
repo = "autobrr";
16+
rev = "v${version}";
17+
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
18+
};
19+
20+
autobrr-web = stdenvNoCC.mkDerivation {
21+
pname = "${pname}-web";
22+
inherit src version;
23+
24+
nativeBuildInputs = [
25+
nodejs
26+
pnpm_9.configHook
27+
typescript
28+
];
29+
30+
sourceRoot = "${src.name}/web";
31+
32+
pnpmDeps = pnpm_9.fetchDeps {
33+
inherit (autobrr-web)
34+
pname
35+
version
36+
src
37+
sourceRoot
38+
;
39+
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
40+
};
41+
42+
postBuild = ''
43+
pnpm run build
44+
'';
45+
46+
installPhase = ''
47+
cp -r dist $out
48+
'';
49+
};
50+
in
51+
buildGoModule rec {
52+
inherit
53+
autobrr-web
54+
pname
55+
version
56+
src
57+
;
58+
59+
vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
60+
61+
preBuild = ''
62+
cp -r ${autobrr-web}/* web/dist
63+
'';
64+
}

0 commit comments

Comments
 (0)