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(gradle): stop mocking the file system #5826

Merged
merged 4 commits into from
Apr 3, 2020

Conversation

jGleitz
Copy link
Contributor

@jGleitz jGleitz commented Mar 29, 2020

Given the mistake I made in #5806, I went ahead and replaced the file system mocking in the gradle tests with real file system accesses. From my point of view, the less we mock, the higher the probability that we find regressions. I could find no good reasons to mock the file system here. The mocking also depended on the precise fs functions the code called, and on the order of those calls.

Even though I think I have good reasons for this change, I realise that it is also a question of philosophy. So feel free to close this pull request if you prefer to keep the file system mocks.

@rarkins rarkins requested a review from viceice March 29, 2020 10:42
Comment on lines 36 to 46
const replacingSerializer = (
search: string,
replacement: string
): jest.SnapshotSerializerPlugin => ({
test: value => typeof value === 'string' && value.includes(search),
serialize: (val, config, indent, depth, refs, printer) => {
const replaced = (val as string).replace(search, replacement);
return printer(replaced, config, indent, depth, refs);
},
});

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a great idea. Could you extract it to test/utils.ts, as there are quite a few places we mock fs to get consistent path names, and this is a much better approach.

JamieMagee
JamieMagee previously approved these changes Mar 30, 2020
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

Yes, please move replacingSerializer to test/utils

@jGleitz
Copy link
Contributor Author

jGleitz commented Apr 2, 2020

Done

@rarkins rarkins merged commit a323cf0 into renovatebot:master Apr 3, 2020
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 19.192.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants