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

Function TestParseDiffText_NewFile

internal/diff/parser_test.go:148–176  ·  view source on GitHub ↗

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

(t *testing.T)

Source from the content-addressed store, hash-verified

146
147// TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
148func TestParseDiffText_NewFile(t *testing.T) {
149 diffText := `diff --git a/fresh.go b/fresh.go
150new file mode 100644
151index 0000000..1234567
152--- /dev/null
153+++ b/fresh.go
154@@ -0,0 +1,2 @@
155+line1
156+line2
157`
158 repo := t.TempDir()
159 diffs, err := ParseDiffText(context.Background(), diffText, repo, "", nil)
160 if err != nil {
161 t.Fatalf("ParseDiffText: %v", err)
162 }
163 if len(diffs) != 1 {
164 t.Fatalf("expected 1 diff, got %d", len(diffs))
165 }
166 d := diffs[0]
167 if !d.IsNew {
168 t.Errorf("IsNew = false, want true")
169 }
170 if d.IsDeleted {
171 t.Errorf("IsDeleted = true, want false")
172 }
173 if d.Insertions != 2 {
174 t.Errorf("Insertions = %d, want 2", d.Insertions)
175 }
176}
177
178// TestParseDiffText_BinaryMarkerAnchored guards two binary-detection cases:
179// 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