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

Function TestParseDiffText_DeletedFile

internal/diff/parser_test.go:184–211  ·  view source on GitHub ↗

TestParseDiffText_DeletedFile guards the /dev/null detection: git emits "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so deletions were misclassified and triggered a doomed `git show ref:path`.

(t *testing.T)

Source from the content-addressed store, hash-verified

182// "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so
183// deletions were misclassified and triggered a doomed `git show ref:path`.
184func TestParseDiffText_DeletedFile(t *testing.T) {
185 diffText := `diff --git a/gone.go b/gone.go
186deleted file mode 100644
187index 1234567..0000000
188--- a/gone.go
189+++ /dev/null
190@@ -1,2 +0,0 @@
191-line1
192-line2
193`
194 diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil)
195 if err != nil {
196 t.Fatalf("ParseDiffText: %v", err)
197 }
198 if len(diffs) != 1 {
199 t.Fatalf("expected 1 diff, got %d", len(diffs))
200 }
201 d := diffs[0]
202 if !d.IsDeleted {
203 t.Errorf("IsDeleted = false, want true")
204 }
205 if d.NewPath != "/dev/null" {
206 t.Errorf("NewPath = %q, want /dev/null", d.NewPath)
207 }
208 if d.OldPath != "gone.go" {
209 t.Errorf("OldPath = %q, want gone.go", d.OldPath)
210 }
211}
212
213// TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
214func TestParseDiffText_NewFile(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected