diff --git a/pkg/commands/patch/patch_modifier_test.go b/pkg/commands/patch/patch_modifier_test.go index a6dfc2716..131490ece 100644 --- a/pkg/commands/patch/patch_modifier_test.go +++ b/pkg/commands/patch/patch_modifier_test.go @@ -223,6 +223,24 @@ func TestModifyPatchForRange(t *testing.T) { -last line \ No newline at end of file +last line +`, + }, + { + testName: "add newline to end of file, reversed", + filename: "filename", + firstLineIndex: -100, + lastLineIndex: 100, + reverse: true, + diffText: addNewlineToEndOfFile, + expected: `--- a/filename ++++ b/filename +@@ -60,4 +60,4 @@ grape + ... + ... + ... +-last line +\ No newline at end of file ++last line `, }, { @@ -240,6 +258,24 @@ func TestModifyPatchForRange(t *testing.T) { -last line +last line \ No newline at end of file +`, + }, + { + testName: "remove newline from end of file, reversed", + filename: "filename", + firstLineIndex: -100, + lastLineIndex: 100, + reverse: true, + diffText: removeNewlinefromEndOfFile, + expected: `--- a/filename ++++ b/filename +@@ -60,4 +60,4 @@ grape + ... + ... + ... +-last line ++last line +\ No newline at end of file `, }, { @@ -255,6 +291,24 @@ func TestModifyPatchForRange(t *testing.T) { ... ... -last line +`, + }, + { + testName: "remove newline from end of file, removal only, reversed", + filename: "filename", + firstLineIndex: 8, + lastLineIndex: 8, + reverse: true, + diffText: removeNewlinefromEndOfFile, + expected: `--- a/filename ++++ b/filename +@@ -60,5 +60,4 @@ grape + ... + ... + ... +-last line + last line +\ No newline at end of file `, }, { @@ -272,6 +326,23 @@ func TestModifyPatchForRange(t *testing.T) { last line +last line \ No newline at end of file +`, + }, + { + testName: "remove newline from end of file, addition only, reversed", + filename: "filename", + firstLineIndex: 9, + lastLineIndex: 9, + reverse: true, + diffText: removeNewlinefromEndOfFile, + expected: `--- a/filename ++++ b/filename +@@ -60,3 +60,4 @@ grape + ... + ... + ... ++last line +\ No newline at end of file `, }, { @@ -363,6 +434,20 @@ func TestModifyPatchForRange(t *testing.T) { @@ -0,0 +1,1 @@ +new line \ No newline at end of file +`, + }, + { + testName: "adding a new line to a previously empty file, reversed", + filename: "newfile", + firstLineIndex: -100, + lastLineIndex: 100, + diffText: addNewlineToPreviouslyEmptyFile, + reverse: true, + expected: `--- a/newfile ++++ b/newfile +@@ -0,0 +1,1 @@ ++new line +\ No newline at end of file `, }, {