Add test for overwriting file in Run function #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes changes to the CLI and its tests in the
internal/cli
package, as well as an update to a test data file. The most significant changes include a minor adjustment to the order ofdefer
statements in theRun
method, the addition of a new test caseTestRun_successForOverwrite
, and an update to thetest_for_overwrite.txt
test data file.Here are the most important changes, grouped by theme:
Order adjustment in CLI:
internal/cli/cli.go
: The order ofdefer
statements in theRun
method was changed. Theos.Remove
call is now placed before thetmpFile.Close
call. This change ensures that the temporary file is removed even if closing the file fails.Addition of new test case:
internal/cli/cli_test.go
: A new test caseTestRun_successForOverwrite
was added. This test case includes several subtests that verify the behavior of the-overwrite
,-replace
, and-filter
options. A helper functioncopyFile
was also added to assist with test setup.Update to test data file:
internal/cli/testdata/test_for_overwrite.txt
: The test data file was updated with new content. This change is likely related to the newTestRun_successForOverwrite
test case.