fix(maven): Snapshot gradle props instead of deleting - #278
fix(maven): Snapshot gradle props instead of deleting#278iker-barriocanal wants to merge 18 commits into
Conversation
BYK
left a comment
There was a problem hiding this comment.
Pushing back for the following reasons:
fs.acccesscheck- Converting this into a wrapper function like
withTempDir() - Converting the tests into "real world" tests instead of implementation checks:
Actually have a file on the file system and instead of mocking these functions, make sure we get back the original states: non-existent gradle file, gradle file with user info. It should also ensure the proper file is created during the process.
BYK
left a comment
There was a problem hiding this comment.
Context manager looks great and see how much it simplifies the code!
| await expect(fsPromises.access(expectedPropsPath)).rejects.toThrowError( | ||
| /ENOENT: no such file/ |
There was a problem hiding this comment.
Why not just expect(fs.exists(expectedPropsPath)).to.not.be.true()?
There was a problem hiding this comment.
Because to and be don't exist. Moving to accessSync since it's cleaner, but if you know an even cleaner way I can update it.
| async () => await testCorrectPropsFile(expectedPropsPath) | ||
| ); | ||
|
|
||
| await mvnTarget.publish('v3rs10n', 'r3v1s10n'); |
There was a problem hiding this comment.
I expected you to test withGradleProps directly here, instead of mocking upload with your test method and then invoking publish. This would be the correct way to write a unit test for your helper.
| }); | ||
| }); | ||
|
|
||
| test('existent props file', async () => { |
There was a problem hiding this comment.
You are missing some test cases:
- What if the callback function throws an error? You should test that we still restore the snapshot/delete our own props file
- What if we simply cannot backup an existing snapshot file? Where's the test case for that?
- What if we cannot restore a snapshot file for some reason?
It's accepted use case to not exist the file. It's not an accepted use case to exist and to not be able to read the file.
|
Superseded by #351 |
From #276 the gradle properties file was removed, causing the loss of any user config that may exist in that file. This PR makes a snapshot of the file at the beginning of the
maventarget execution and restores it at the end, so the user config shouldn't be affected.