TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
(t *testing.T)
| 143 | |
| 144 | // TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix). |
| 145 | func TestParseDiffText_NewFile(t *testing.T) { |
| 146 | diffText := `diff --git a/fresh.go b/fresh.go |
| 147 | new file mode 100644 |
| 148 | index 0000000..1234567 |
| 149 | --- /dev/null |
| 150 | +++ b/fresh.go |
| 151 | @@ -0,0 +1,2 @@ |
| 152 | +line1 |
| 153 | +line2 |
| 154 | ` |
| 155 | repo := t.TempDir() |
| 156 | diffs, err := ParseDiffText(context.Background(), diffText, repo, "", nil) |
| 157 | if err != nil { |
| 158 | t.Fatalf("ParseDiffText: %v", err) |
| 159 | } |
| 160 | if len(diffs) != 1 { |
| 161 | t.Fatalf("expected 1 diff, got %d", len(diffs)) |
| 162 | } |
| 163 | d := diffs[0] |
| 164 | if !d.IsNew { |
| 165 | t.Errorf("IsNew = false, want true") |
| 166 | } |
| 167 | if d.IsDeleted { |
| 168 | t.Errorf("IsDeleted = true, want false") |
| 169 | } |
| 170 | if d.Insertions != 2 { |
| 171 | t.Errorf("Insertions = %d, want 2", d.Insertions) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | // TestParseDiffText_BinaryMarkerAnchored guards two binary-detection cases: |
| 176 | // a text file whose CONTENT mentions "Binary files " must not be classified |
nothing calls this directly
no test coverage detected