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

Function TestParseDiffText_DeletedFile

internal/diff/parser_test.go:115–142  ·  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

113// "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so
114// deletions were misclassified and triggered a doomed `git show ref:path`.
115func TestParseDiffText_DeletedFile(t *testing.T) {
116 diffText := `diff --git a/gone.go b/gone.go
117deleted file mode 100644
118index 1234567..0000000
119--- a/gone.go
120+++ /dev/null
121@@ -1,2 +0,0 @@
122-line1
123-line2
124`
125 diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil)
126 if err != nil {
127 t.Fatalf("ParseDiffText: %v", err)
128 }
129 if len(diffs) != 1 {
130 t.Fatalf("expected 1 diff, got %d", len(diffs))
131 }
132 d := diffs[0]
133 if !d.IsDeleted {
134 t.Errorf("IsDeleted = false, want true")
135 }
136 if d.NewPath != "/dev/null" {
137 t.Errorf("NewPath = %q, want /dev/null", d.NewPath)
138 }
139 if d.OldPath != "gone.go" {
140 t.Errorf("OldPath = %q, want gone.go", d.OldPath)
141 }
142}
143
144// TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
145func TestParseDiffText_NewFile(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected