Test moving a file into a new directory
(t *testing.T)
| 123 | |
| 124 | // Test moving a file into a new directory |
| 125 | func 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 |
| 166 | func TestCommitsRenameDeepDir(t *testing.T) { |
nothing calls this directly
no test coverage detected