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

Function TestParseDiffText_DeletedFile

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

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

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected