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

Function TestParseDiffText_DeletedFile

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

71// "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so
72// deletions were misclassified and triggered a doomed `git show ref:path`.
73func TestParseDiffText_DeletedFile(t *testing.T) {
74 diffText := `diff --git a/gone.go b/gone.go
75deleted file mode 100644
76index 1234567..0000000
77--- a/gone.go
78+++ /dev/null
79@@ -1,2 +0,0 @@
80-line1
81-line2
82`
83 diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil)
84 if err != nil {
85 t.Fatalf("ParseDiffText: %v", err)
86 }
87 if len(diffs) != 1 {
88 t.Fatalf("expected 1 diff, got %d", len(diffs))
89 }
90 d := diffs[0]
91 if !d.IsDeleted {
92 t.Errorf("IsDeleted = false, want true")
93 }
94 if d.NewPath != "/dev/null" {
95 t.Errorf("NewPath = %q, want /dev/null", d.NewPath)
96 }
97 if d.OldPath != "gone.go" {
98 t.Errorf("OldPath = %q, want gone.go", d.OldPath)
99 }
100}
101
102// TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix).
103func TestParseDiffText_NewFile(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected