Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always re-create package-lock.json #43

Merged
merged 1 commit into from
Sep 3, 2023

Conversation

ruromero
Copy link
Contributor

Description

Always re-create the package-lock.json because after the user updates the package.json file, the extension will run another analysis and it will fail because the package-lock.json is not synchronized.

Related issue (if any): fixes #issue_number_goes_here

Checklist

  • I have followed this repository's contributing guidelines.
  • I will adhere to the project's code of conduct.

Signed-off-by: Ruben Romero Montes <[email protected]>
@ruromero ruromero requested a review from zvigrinberg August 31, 2023 14:36
Copy link
Collaborator

@zvigrinberg zvigrinberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might break the unitests , but it's crucial to the process of updating the package.json and gets the new data of the new added dependencies, which is more important.

the problem with UT, is that recalculating package.json' package-lock.json everytime might change the versions of the transitive fetched dependencies over time, thus it might break the tests as the expected sboms will be different from the actual ones ( this was the reason why there is package-lock.json file in each test' directory of npm) - hence will need to change the expected sbom everytime it's changing, or to mock the call for npm, which will save us from doing this tedious task.

Hence in order to overcome the above tests' problem, i have no choice but to mock the calls to npm ( npm i and npm ls), thing that anyway i planned to do sooner or later for unitests - now i have 3 reasons to do so - performance and reducing run time for UT, saving time from changing expected sboms everytime it changes , and third and last, which is the first motivation to do so, is that UT should be concerned only with logic of the library' code alone, and not with testing how the code integrates with the package manager cli tool ( in this case - npm) , this should be left to be tested in component tests/integration tests.

Will do so either on first opportunity or on first failure of UT that caused by that, whichever comes first.

Anyway, lgtm and approved

@zvigrinberg zvigrinberg merged commit 2371856 into RHEcosystemAppEng:main Sep 3, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants