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

Function TestParseDiffText_NewFile

internal/diff/parser_test.go:103–131  ·  view source on GitHub ↗

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

(t *testing.T)

Source from the content-addressed store, hash-verified

101
102// TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
103func TestParseDiffText_NewFile(t *testing.T) {
104 diffText := `diff --git a/fresh.go b/fresh.go
105new file mode 100644
106index 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

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected