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

scaffolder-backend: refactor tests to avoid mock-fs #20404

Merged
merged 13 commits into from
Oct 6, 2023

Conversation

Rugvip
Copy link
Member

@Rugvip Rugvip commented Oct 5, 2023

After #20399 these should be the last fixes needed for us to be able to run test towards Node.js 20 again. There's still 24 more tests that use mock-fs, thinking we'll leave those for contributions as they're less urgent and it'd be good to get some more feedback on the MockDirectory API.

This PR introduces two more changes to the MockDirectory API. It reverts to using default file modes, since explicit modes should be unnecessary.

It also adds a new callback format for writing content to the mock dir, used for more specific file system operations than just "a file" or "a directory". It's in the form of a callback that will be called once the directory content serialization has gotten to the point of that item. The parent directory will always exist, and the target path is provided as part of the callback context, which makes it simple to execute arbitrary synchronous filesystem operations at that location. There is also a symlink(target) helper that creates a symlink at the location. This is a bit different than the graph-based approach that mock-fs uses, but feels like it provides a lot more power with a slimmer API surface, with the drawback being that it's a much more specific and synchronous API.

@Rugvip Rugvip requested review from backstage-service and a team as code owners October 5, 2023 20:05
@Rugvip Rugvip requested review from freben and vinzscam and removed request for a team October 5, 2023 20:05
@github-actions github-actions bot added the area:scaffolder Everything and all things related to the scaffolder project area label Oct 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

Uffizzi Preview deployment-37794 was deleted.

@Rugvip Rugvip force-pushed the rugvip/scaffodler-no-mockfs branch from c3f257e to 7d077ae Compare October 6, 2023 10:47
Base automatically changed from rugvip/more-20-fixes to master October 6, 2023 11:29
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
…k-fs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
… modes

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
…ock-fs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
…ck-fs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@Rugvip Rugvip force-pushed the rugvip/scaffodler-no-mockfs branch from 7d077ae to 94e3cb2 Compare October 6, 2023 11:31
@backstage-goalie
Copy link
Contributor

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage/backend-test-utils
  • @backstage/plugin-scaffolder-backend

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/backend-test-utils packages/backend-test-utils none v0.2.6-next.1
@backstage/plugin-scaffolder-backend plugins/scaffolder-backend none v1.18.0-next.1

@Rugvip Rugvip merged commit 2af75ac into master Oct 6, 2023
31 checks passed
@Rugvip Rugvip deleted the rugvip/scaffodler-no-mockfs branch October 6, 2023 12:33
taliesins added a commit to taliesins/backstage-showcase that referenced this pull request Mar 27, 2024
…the unit tests. Mock-fs was failing to read and test for mocked files.
taliesins added a commit to taliesins/backstage-showcase that referenced this pull request Mar 27, 2024
…the unit tests. Mock-fs was failing to read and test for mocked files.
taliesins added a commit to taliesins/backstage-showcase that referenced this pull request Mar 27, 2024
…the unit tests. Mock-fs was failing to read and test for mocked files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:scaffolder Everything and all things related to the scaffolder project area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants