(t *testing.T)
| 234 | } |
| 235 | |
| 236 | func TestDiffModesPreserveNonASCIIPaths(t *testing.T) { |
| 237 | tests := []struct { |
| 238 | name string |
| 239 | provider func(t *testing.T, repo string, runner *gitcmd.Runner) *Provider |
| 240 | }{ |
| 241 | { |
| 242 | name: "workspace", |
| 243 | provider: func(_ *testing.T, repo string, runner *gitcmd.Runner) *Provider { |
| 244 | return NewWorkspaceProvider(repo, runner) |
| 245 | }, |
| 246 | }, |
| 247 | { |
| 248 | name: "commit", |
| 249 | provider: func(t *testing.T, repo string, runner *gitcmd.Runner) *Provider { |
| 250 | runGitTest(t, repo, "add", "-A") |
| 251 | runGitTest(t, repo, "commit", "-q", "-m", "update non-ASCII file") |
| 252 | return NewCommitProvider(repo, "HEAD", runner) |
| 253 | }, |
| 254 | }, |
| 255 | { |
| 256 | name: "range", |
| 257 | provider: func(t *testing.T, repo string, runner *gitcmd.Runner) *Provider { |
| 258 | runGitTest(t, repo, "add", "-A") |
| 259 | runGitTest(t, repo, "commit", "-q", "-m", "update non-ASCII file") |
| 260 | return NewProvider(repo, "HEAD~1", "HEAD", runner) |
| 261 | }, |
| 262 | }, |
| 263 | } |
| 264 | |
| 265 | for _, tt := range tests { |
| 266 | t.Run(tt.name, func(t *testing.T) { |
| 267 | repo, relPath := initRepoWithNonASCIIChange(t) |
| 268 | provider := tt.provider(t, repo, gitcmd.New(0)) |
| 269 | |
| 270 | diffs, err := provider.GetDiff(context.Background()) |
| 271 | if err != nil { |
| 272 | t.Fatalf("GetDiff returned error: %v", err) |
| 273 | } |
| 274 | if len(diffs) != 1 { |
| 275 | t.Fatalf("got %d diffs, want 1: %+v", len(diffs), diffs) |
| 276 | } |
| 277 | if diffs[0].NewPath != relPath { |
| 278 | t.Errorf("NewPath = %q, want %q", diffs[0].NewPath, relPath) |
| 279 | } |
| 280 | if diffs[0].NewFileContent != "after\n" { |
| 281 | t.Errorf("NewFileContent = %q, want %q", diffs[0].NewFileContent, "after\n") |
| 282 | } |
| 283 | }) |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | func TestWorkspaceDiffPreservesNonASCIIUntrackedPath(t *testing.T) { |
| 288 | repo, trackedPath := initRepoWithNonASCIIChange(t) |
nothing calls this directly
no test coverage detected