MCPcopy Index your code
hub / github.com/sinclairtarget/git-who / TestCommitsFileRenameNewDir

Function TestCommitsFileRenameNewDir

internal/git/parse_test.go:125–163  ·  view source on GitHub ↗

Test moving a file into a new directory

(t *testing.T)

Source from the content-addressed store, hash-verified

123
124// Test moving a file into a new directory
125func TestCommitsFileRenameNewDir(t *testing.T) {
126 lines := readDump(renameNewDirDump)
127
128 seq, finish := git.ParseCommits(lines)
129 commits := slices.Collect(seq)
130 err := finish()
131 if err != nil {
132 t.Fatalf("error iterating commits: %v", err)
133 }
134
135 if len(commits) != 2 {
136 t.Fatalf("expected 2 commits but found %d", len(commits))
137 }
138
139 commit := commits[1]
140 if commit.Hash != "13b6f4f70c682ab06da9ef433cdb4fcbf65d78c3" {
141 t.Errorf(
142 "expected commit to have hash %s but got %s",
143 "13b6f4f70c682ab06da9ef433cdb4fcbf65d78c3",
144 commit.Hash,
145 )
146 }
147
148 if len(commit.FileDiffs) != 1 {
149 t.Errorf(
150 "len of commit file diffs should be 1, but got %d",
151 len(commit.FileDiffs),
152 )
153 }
154
155 diff := commit.FileDiffs[0]
156 if diff.Path != "rename-new-dir/foo/hello.txt" {
157 t.Errorf(
158 "expected diff path to be %s but got \"%s\"",
159 "rename-new-dir/foo/hello.txt",
160 diff.Path,
161 )
162 }
163}
164
165// Test moving where change will look like /foo/{bim/bar => baz/biz}/hello.txt
166func TestCommitsRenameDeepDir(t *testing.T) {

Callers

nothing calls this directly

Calls 2

ParseCommitsFunction · 0.92
readDumpFunction · 0.85

Tested by

no test coverage detected