Skip to content

Commit 2f934ea

Browse files
committed
Add test for git and local source resolution
1 parent 6e628b4 commit 2f934ea

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

node/tests/test_pnpm.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from flatpak_node_generator.integrity import Integrity
66
from flatpak_node_generator.package import (
7+
GitSource,
8+
LocalSource,
79
Lockfile,
810
Package,
911
ResolvedSource,
@@ -259,3 +261,67 @@ def test_lockfile_v9_no_devel_warns(
259261
captured = capsys.readouterr()
260262
assert '--no-devel is not yet supported for pnpm lockfile v9' in captured.err
261263
assert len(packages) == 3
264+
265+
266+
TEST_LOCKFILE_V9_GIT_AND_LOCAL = """
267+
lockfileVersion: '9.0'
268+
269+
settings:
270+
autoInstallPeers: true
271+
excludeLinksFromLockfile: false
272+
273+
importers:
274+
.:
275+
dependencies:
276+
my-git-pkg:
277+
specifier: github:user/repo#abc123
278+
version: github.com/user/repo/abc123
279+
my-local-pkg:
280+
specifier: file:../local-pkg
281+
version: file:../local-pkg
282+
283+
packages:
284+
my-git-pkg@github.com/user/repo/abc123:
285+
resolution: {type: git, repo: https://github.com/user/repo, commit: abc123def456}
286+
287+
my-local-pkg@file:../local-pkg:
288+
resolution: {directory: ../local-pkg}
289+
290+
snapshots:
291+
my-git-pkg@github.com/user/repo/abc123: {}
292+
my-local-pkg@file:../local-pkg: {}
293+
"""
294+
295+
296+
def test_lockfile_v9_git_and_local(tmp_path: Path) -> None:
297+
provider = PnpmLockfileProvider(
298+
PnpmLockfileProvider.Options(
299+
no_devel=False,
300+
registry='https://registry.npmjs.org',
301+
)
302+
)
303+
304+
lockfile = Lockfile(tmp_path / 'pnpm-lock.yaml', 9)
305+
lockfile.path.write_text(TEST_LOCKFILE_V9_GIT_AND_LOCAL)
306+
307+
packages = list(provider.process_lockfile(lockfile.path))
308+
309+
assert packages == [
310+
Package(
311+
lockfile=lockfile,
312+
name='my-git-pkg',
313+
version='github.com/user/repo/abc123',
314+
source=GitSource(
315+
original='git+https://github.com/user/repo#abc123def456',
316+
url='https://github.com/user/repo',
317+
commit='abc123def456',
318+
from_=None,
319+
),
320+
),
321+
Package(
322+
lockfile=lockfile,
323+
name='my-local-pkg',
324+
version='file:../local-pkg',
325+
source=LocalSource(path='../local-pkg'),
326+
),
327+
]

0 commit comments

Comments
 (0)