Skip to content

Commit ba62c45

Browse files
committed
Add test for rename support in multi file diff.
Followup for #9 (comment). This test passes now, but would fail before #9 was merged.
1 parent 66ef784 commit ba62c45

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

diff/diff_test.go

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,10 @@ func TestParseHunksAndPrintHunks(t *testing.T) {
5454
filename string
5555
wantParseErr error
5656
}{
57-
{
58-
filename: "sample_hunk.diff",
59-
},
60-
{
61-
filename: "sample_hunks.diff",
62-
},
63-
{
64-
filename: "sample_bad_hunks.diff",
65-
wantParseErr: nil,
66-
},
67-
{
68-
filename: "sample_hunks_no_newline.diff",
69-
},
57+
{filename: "sample_hunk.diff"},
58+
{filename: "sample_hunks.diff"},
59+
{filename: "sample_bad_hunks.diff"},
60+
{filename: "sample_hunks_no_newline.diff"},
7061
{filename: "no_newline_both.diff"},
7162
{filename: "no_newline_both2.diff"},
7263
{filename: "no_newline_orig.diff"},
@@ -105,15 +96,9 @@ func TestParseFileDiffAndPrintFileDiff(t *testing.T) {
10596
filename string
10697
wantParseErr error
10798
}{
108-
{
109-
filename: "sample_file.diff",
110-
},
111-
{
112-
filename: "sample_file_no_timestamp.diff",
113-
},
114-
{
115-
filename: "sample_file_extended.diff",
116-
},
99+
{filename: "sample_file.diff"},
100+
{filename: "sample_file_no_timestamp.diff"},
101+
{filename: "sample_file_extended.diff"},
117102
{
118103
filename: "empty.diff",
119104
wantParseErr: &ParseError{0, 0, ErrExtendedHeadersEOF},
@@ -145,20 +130,16 @@ func TestParseFileDiffAndPrintFileDiff(t *testing.T) {
145130

146131
func TestParseMultiFileDiffAndPrintMultiFileDiff(t *testing.T) {
147132
tests := []struct {
148-
filename string
149-
wantParseErr error
133+
filename string
134+
wantParseErr error
135+
wantFileDiffs int // How many instances of diff.FileDiff are expected.
150136
}{
151-
{
152-
filename: "sample_multi_file.diff",
153-
},
154-
{
155-
filename: "sample_multi_file_single.diff",
156-
},
157-
{
158-
filename: "long_line_multi.diff",
159-
},
160-
{filename: "empty.diff"},
161-
{filename: "empty_multi.diff"},
137+
{filename: "sample_multi_file.diff", wantFileDiffs: 2},
138+
{filename: "sample_multi_file_single.diff", wantFileDiffs: 1},
139+
{filename: "sample_multi_file_rename.diff", wantFileDiffs: 3},
140+
{filename: "long_line_multi.diff", wantFileDiffs: 3},
141+
{filename: "empty.diff", wantFileDiffs: 0},
142+
{filename: "empty_multi.diff", wantFileDiffs: 2},
162143
}
163144
for _, test := range tests {
164145
diffData, err := ioutil.ReadFile(filepath.Join("testdata", test.filename))
@@ -174,6 +155,10 @@ func TestParseMultiFileDiffAndPrintMultiFileDiff(t *testing.T) {
174155
continue
175156
}
176157

158+
if got, want := len(diff), test.wantFileDiffs; got != want {
159+
t.Errorf("%s: got %v instances of diff.FileDiff, expected %v", test.filename, got, want)
160+
}
161+
177162
printed, err := PrintMultiFileDiff(diff)
178163
if err != nil {
179164
t.Errorf("%s: PrintMultiFileDiff: %s", test.filename, err)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff --git a/README.md b/README.md
2+
index 5f3d591..96a24fa 100644
3+
--- a/README.md
4+
+++ b/README.md
5+
@@ -24,6 +24,8 @@ and [view enterprise capabilities](https://www.example.com).*
6+
7+
## Installation
8+
9+
+Minor change here.
10+
+
11+
Follow the 5-minute
12+
[installation instructions](https://www.example.com/.docs/getting-started/). For
13+
more installation methods, check out the
14+
diff --git a/docs/integrations/Email_Notifications.md b/docs/integrations/email-notifications.md
15+
similarity index 100%
16+
rename from docs/integrations/Email_Notifications.md
17+
rename to docs/integrations/email-notifications.md
18+
diff --git a/release_notes.md b/release_notes.md
19+
index f2ff13f..f060cb5 100644
20+
--- a/release_notes.md
21+
+++ b/release_notes.md
22+
@@ -1,3 +1,5 @@
23+
+# new section
24+
+
25+
# dev
26+
27+
- Removed example pages and the `--auth.example-flag`

0 commit comments

Comments
 (0)