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

Function TestParseDiffText_PureRename

internal/diff/parser_test.go:95–113  ·  view source on GitHub ↗

TestParseDiffText_PureRename covers a 100% similarity rename, which carries no hunks and no ---/+++ lines at all.

(t *testing.T)

Source from the content-addressed store, hash-verified

93// TestParseDiffText_PureRename covers a 100% similarity rename, which carries
94// no hunks and no ---/+++ lines at all.
95func TestParseDiffText_PureRename(t *testing.T) {
96 diffText := `diff --git a/old.go b/new.go
97similarity index 100%
98rename from old.go
99rename to new.go
100`
101 diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil)
102 if err != nil {
103 t.Fatalf("ParseDiffText: %v", err)
104 }
105 if len(diffs) != 1 {
106 t.Fatalf("expected 1 diff, got %d", len(diffs))
107 }
108 d := diffs[0]
109 if !d.IsRenamed || d.OldPath != "old.go" || d.NewPath != "new.go" {
110 t.Errorf("got IsRenamed=%v OldPath=%q NewPath=%q, want true/old.go/new.go",
111 d.IsRenamed, d.OldPath, d.NewPath)
112 }
113}
114
115// TestParseDiffText_DeletedFile guards the /dev/null detection: git emits
116// "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so

Callers

nothing calls this directly

Calls 1

ParseDiffTextFunction · 0.85

Tested by

no test coverage detected