Skip to content

Commit

Permalink
Add test for package-lock.json #3931
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Oct 8, 2024
1 parent 762078c commit 8b63e76
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 6 deletions.
57 changes: 57 additions & 0 deletions tests/packagedcode/data/npm/alias/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 149 additions & 0 deletions tests/packagedcode/data/npm/alias/package-lock.json.expected

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions tests/packagedcode/test_npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ def test_parse_package_lock_v2_2(self):
packages = npm.NpmPackageLockJsonHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)

def test_parse_package_lock_v2_alias(self):
test_file = self.get_test_loc('npm/alias/package-lock.json')
expected_loc = self.get_test_loc(
'npm/alias/package-lock.json.expected')
packages = npm.NpmPackageLockJsonHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)

def test_is_datafile_npm_shrinkwrap_json(self):
test_file = self.get_test_loc('npm/npm-shrinkwrap/npm-shrinkwrap.json')
assert npm.NpmShrinkwrapJsonHandler.is_datafile(test_file)
Expand Down Expand Up @@ -360,10 +367,10 @@ def test_npm_yarn_with_package_json_resolve_dependencies(self):
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
)

def test_npm_yarn_lock_v1_parse_with_other_version_constraint(self):
test_file = self.get_test_loc('npm/yarn-lock/v1-other-constraint/yarn.lock')
def test_npm_yarn_lock_v1_parse_alias(self):
test_file = self.get_test_loc('npm/yarn-lock/v1-alias/yarn.lock')
expected_loc = self.get_test_loc(
'npm/yarn-lock/v1-other-constraint/yarn.lock-expected')
'npm/yarn-lock/v1-alias/yarn.lock-expected')
packages = npm.YarnLockV1Handler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)

Expand Down Expand Up @@ -393,9 +400,9 @@ def test_parse_pnpm_shrinkwrap_yaml(self):
packages = npm.PnpmLockYamlHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)

def test_parse_package_json_special_dep_requirements(self):
test_file = self.get_test_loc('npm/special_extracted_requirements/package.json')
expected_loc = self.get_test_loc('npm/special_extracted_requirements/package.json.expected')
def test_parse_package_json_alias_requirements(self):
test_file = self.get_test_loc('npm/alias/package.json')
expected_loc = self.get_test_loc('npm/alias/package.json.expected')
packages = npm.NpmPackageJsonHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)

Expand Down

0 comments on commit 8b63e76

Please sign in to comment.