MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestParseDiffText_NewFile

Function TestParseDiffText_NewFile

internal/diff/parser_test.go:214–242  ·  view source on GitHub ↗

TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).

(t *testing.T)

Source from the content-addressed store, hash-verified

212
213// TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
214func TestParseDiffText_NewFile(t *testing.T) {
215 diffText := `diff --git a/fresh.go b/fresh.go
216new file mode 100644
217index 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

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected