Skip to content
New issue

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

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

Already on GitHub? # to your account

Add testutils.MakeMemMapFs test helper #3933

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Sep 5, 2024

What?

This is a small refactoring and low priority, review it when you have capacity, no rush 🙇🏻

This PR introduces a MakeMemMapFs test helper to the testutils package.

This helper function creates a new in-memory filesystem with the given files. It is particularly useful for testing code that interacts with the filesystem, as it allows the creation of a filesystem with a known state without having to create temporary directories and files on disk.

Why?

While working on another PR, I was looking for a way to initialize a test Fs quickly. I found in the codebase occurences of a makeMemMapFs function, which was already duplicated twice in the codebase.

In the spirit of continuous improvement, instead of adding a third copy, I thought I would make a testutil function out of it.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

While working on another PR I was looking for a way to quickly
initialize a test Fs. I found in the codebase occurences of a
makeMemMapFs function, which was already duplicated twice in the
codebase.

Instead of adding a third copy, I thought I would instead make testutil
out of it. This is exactly what this commit does.
@oleiade oleiade self-assigned this Sep 5, 2024
@oleiade oleiade requested a review from a team as a code owner September 5, 2024 12:47
@oleiade oleiade requested review from mstoykov and joanlopez and removed request for a team September 5, 2024 12:47
Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

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

Looks good to me, the only question I have is: now that we're planning v1.0, do we really want to expose it under: /lib/..., or should we (at least first) add it internally? 🤔 Although, it's also true that it might be useful for writing some extensions tests.

Let's see what others say.

@oleiade oleiade merged commit 007660a into master Sep 6, 2024
22 checks passed
@oleiade oleiade deleted the refactor/testutils_makememmapfs branch September 6, 2024 15:01
@olegbespalov olegbespalov added this to the v0.54.0 milestone Sep 11, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants