Skip to content

Commit

Permalink
test: add a test for npm lock generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Moraxyc committed Dec 16, 2024
1 parent f763ab3 commit 403966c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/test_npm_lock_generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import subprocess

import conftest

from nix_update import main


def test_update(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(
[
"--file",
str(path),
"--commit",
"npm-lock-generate",
"--version",
"v2.6.0",
"--generate-lockfile",
]
)
npm_deps_name = subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"npm-lock-generate.npmDeps.name",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
diff = subprocess.run(
["git", "-C", path, "show"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(diff)
assert "2.6.0" in npm_deps_name
assert (
"https://github.com/olrtg/emmet-language-server/compare/v2.5.0...v2.6.0"
in diff
)
1 change: 1 addition & 0 deletions tests/testpkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
savanna = pkgs.python3.pkgs.callPackage ./savanna.nix { };
npm = pkgs.callPackage ./npm.nix { };
npm-package = pkgs.callPackage ./npm-package.nix { };
npm-lock-generate = pkgs.callPackage ./npm-lock-generate { };
pnpm = pkgs.callPackage ./pnpm.nix { };
maven = pkgs.callPackage ./maven.nix { };
mix = pkgs.callPackage ./mix.nix { };
Expand Down
23 changes: 23 additions & 0 deletions tests/testpkgs/npm-lock-generate/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
buildNpmPackage,
fetchFromGitHub,
}:

buildNpmPackage rec {
pname = "emmet-language-server";
version = "2.5.0";

src = fetchFromGitHub {
owner = "olrtg";
repo = "emmet-language-server";
rev = "v${version}";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};

npmDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";

postPatch = ''
cp ${./package-lock.json} ./package-lock.json
'';

}
Empty file.

0 comments on commit 403966c

Please sign in to comment.