TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
(t *testing.T)
| 212 | |
| 213 | // TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix). |
| 214 | func TestParseDiffText_NewFile(t *testing.T) { |
| 215 | diffText := `diff --git a/fresh.go b/fresh.go |
| 216 | new file mode 100644 |
| 217 | index 0000000..1234567 |
| 218 | --- /dev/null |
| 219 | +++ b/fresh.go |
| 220 | @@ -0,0 +1,2 @@ |
| 221 | +line1 |
| 222 | +line2 |
| 223 | ` |
| 224 | repo := t.TempDir() |
| 225 | diffs, err := ParseDiffText(context.Background(), diffText, repo, "", nil) |
| 226 | if err != nil { |
| 227 | t.Fatalf("ParseDiffText: %v", err) |
| 228 | } |
| 229 | if len(diffs) != 1 { |
| 230 | t.Fatalf("expected 1 diff, got %d", len(diffs)) |
| 231 | } |
| 232 | d := diffs[0] |
| 233 | if !d.IsNew { |
| 234 | t.Errorf("IsNew = false, want true") |
| 235 | } |
| 236 | if d.IsDeleted { |
| 237 | t.Errorf("IsDeleted = true, want false") |
| 238 | } |
| 239 | if d.Insertions != 2 { |
| 240 | t.Errorf("Insertions = %d, want 2", d.Insertions) |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | // TestParseDiffText_BinaryMarkerAnchored guards two binary-detection cases: |
| 245 | // a text file whose CONTENT mentions "Binary files " must not be classified |
nothing calls this directly
no test coverage detected