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

test(npm): use fs test utils in extract/pnpm.spec.ts #33756

Merged

Conversation

fpapado
Copy link
Contributor

@fpapado fpapado commented Jan 22, 2025

Changes

This PR is split off from #33376, specifically the discussion at #33376 (comment). It changes tests in lib/modules/manager/npm/extract/pnpm.spec.ts to use the shared fs test utilities. cc @secustor ✉️

The fs test utilities are used by most test suites. This suite was an outlier, instead using spyOn as a way to implement partial mocks, letting other calls of the fs module fall through to the real implementation.

The test utilities assume that the whole fs module is mocked, so I made relevant changes to ensure that. A couple of tests were incidentally relying on the "real" implementation (primarily for path manipulation). For those, I explicitly passed the real version of the relevant functions to them. I think this still has some of the pitfalls of partial mocking, but it is more explicit about what is going on. The blast radius is also isolated to those couple of tests that are relying on this behaviour, instead of the whole suite.

Context

Making these tests more consistent with other test suites, and paving the way for using the fs test utilities in #33376.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@rarkins rarkins enabled auto-merge January 22, 2025 12:58
@rarkins rarkins requested a review from secustor January 22, 2025 12:58
Copy link
Collaborator

@secustor secustor left a comment

Choose a reason for hiding this comment

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

This change is reducing the coverage.
I have retried the pipeline just to be sure it is not a hiccup

auto-merge was automatically disabled January 22, 2025 14:08

Head branch was pushed to by a user without write access

@fpapado
Copy link
Contributor Author

fpapado commented Jan 22, 2025

This change is reducing the coverage. I have retried the pipeline just to be sure it is not a hiccup

Oh, you are right, I remember running into this issue in the other branch. I made a similar fix now in 4ccb0cf. The gist is that the same tests were relying on reading the workspace file from the fixtures directory. While the tests do not fail if they do not read the file, they do not get to cover the same validations that they would have otherwise.

@secustor secustor added this pull request to the merge queue Jan 22, 2025
Merged via the queue into renovatebot:main with commit ff99265 Jan 22, 2025
39 checks passed
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 39.122.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

SuperSandro2000 added a commit to SuperSandro2000/renovate that referenced this pull request Jan 23, 2025
* upstream/main: (73 commits)
  fix(cargo): Skip "replace" range upgrade if new version still matches (renovatebot#33773)
  feat(presets): Add nestjs/config to nest monorepo (renovatebot#33785)
  chore(deps): update python:3.13 docker digest to 6ee7975 (renovatebot#33781)
  chore(deps): update dependency @types/node to v22.10.7 (renovatebot#33780)
  feat: Drop older `timeStamp` field support (renovatebot#33734)
  feat: Switch to `Timestamp` type (renovatebot#33648)
  chore(deps): update github/codeql-action action to v3.28.3 (renovatebot#33767)
  build(deps): update dependency @renovatebot/osv-offline to v1.5.12 (renovatebot#33766)
  build(deps): update dependency fs-extra to v11.3.0 (renovatebot#33765)
  chore(deps): update codecov/codecov-action action to v5.2.0 (renovatebot#33763)
  build(deps): update dependency cronstrue to v2.53.0 (renovatebot#33762)
  docs: added list of valid namespace codes for the cacheTtlOverride config (renovatebot#33754)
  test(npm): use fs test utils in extract/pnpm.spec.ts (renovatebot#33756)
  docs: remove platform information from Mend-hosted App config page (renovatebot#33724)
  feat(presets): add monorepo html-eslint (renovatebot#33730)
  feat(presets): add arrow-kt monorepo (renovatebot#33740)
  build(deps): update dependency better-sqlite3 to v11.8.0 (renovatebot#33750)
  chore(deps): update dependency eslint-plugin-jest to v28.11.0 (renovatebot#33749)
  chore(deps): update dependency eslint-plugin-jest to v28.10.1 (renovatebot#33747)
  chore(deps): update otel/opentelemetry-collector-contrib docker tag to v0.118.0 (renovatebot#33746)
  ...
mblum14 added a commit to mblum14/renovate that referenced this pull request Jan 23, 2025
* upstream/main: (61 commits)
  docs: announce upcoming disabling of encrypted secrets (renovatebot#33803)
  chore(deps): update codecov/codecov-action action to v5.3.0 (renovatebot#33805)
  fix(deps): update ghcr.io/containerbase/sidecar docker tag to v13.7.0 (renovatebot#33802)
  chore(deps): update github/codeql-action action to v3.28.4 (renovatebot#33798)
  chore(deps): update ghcr.io/containerbase/devcontainer docker tag to v13.7.0 (renovatebot#33799)
  feat(datasource/hackage): Detect deprecation status (renovatebot#33778)
  fix(cargo): Skip "replace" range upgrade if new version still matches (renovatebot#33773)
  feat(presets): Add nestjs/config to nest monorepo (renovatebot#33785)
  chore(deps): update python:3.13 docker digest to 6ee7975 (renovatebot#33781)
  chore(deps): update dependency @types/node to v22.10.7 (renovatebot#33780)
  feat: Drop older `timeStamp` field support (renovatebot#33734)
  feat: Switch to `Timestamp` type (renovatebot#33648)
  chore(deps): update github/codeql-action action to v3.28.3 (renovatebot#33767)
  build(deps): update dependency @renovatebot/osv-offline to v1.5.12 (renovatebot#33766)
  build(deps): update dependency fs-extra to v11.3.0 (renovatebot#33765)
  chore(deps): update codecov/codecov-action action to v5.2.0 (renovatebot#33763)
  build(deps): update dependency cronstrue to v2.53.0 (renovatebot#33762)
  docs: added list of valid namespace codes for the cacheTtlOverride config (renovatebot#33754)
  test(npm): use fs test utils in extract/pnpm.spec.ts (renovatebot#33756)
  docs: remove platform information from Mend-hosted App config page (renovatebot#33724)
  ...
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.

3 participants