TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
(t *testing.T)
| 101 | |
| 102 | // TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix). |
| 103 | func TestParseDiffText_NewFile(t *testing.T) { |
| 104 | diffText := `diff --git a/fresh.go b/fresh.go |
| 105 | new file mode 100644 |
| 106 | index 0000000..1234567 |
| 107 | --- /dev/null |
| 108 | +++ b/fresh.go |
| 109 | @@ -0,0 +1,2 @@ |
| 110 | +line1 |
| 111 | +line2 |
| 112 | ` |
| 113 | repo := t.TempDir() |
| 114 | diffs, err := ParseDiffText(context.Background(), diffText, repo, "", nil) |
| 115 | if err != nil { |
| 116 | t.Fatalf("ParseDiffText: %v", err) |
| 117 | } |
| 118 | if len(diffs) != 1 { |
| 119 | t.Fatalf("expected 1 diff, got %d", len(diffs)) |
| 120 | } |
| 121 | d := diffs[0] |
| 122 | if !d.IsNew { |
| 123 | t.Errorf("IsNew = false, want true") |
| 124 | } |
| 125 | if d.IsDeleted { |
| 126 | t.Errorf("IsDeleted = true, want false") |
| 127 | } |
| 128 | if d.Insertions != 2 { |
| 129 | t.Errorf("Insertions = %d, want 2", d.Insertions) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // TestParseDiffText_BinaryMarkerAnchored guards two binary-detection cases: |
| 134 | // a text file whose CONTENT mentions "Binary files " must not be classified |
nothing calls this directly
no test coverage detected