(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func TestDiffModesPreserveNonASCIIPaths(t *testing.T) { |
| 99 | tests := []struct { |
| 100 | name string |
| 101 | provider func(t *testing.T, repo string, runner *gitcmd.Runner) *Provider |
| 102 | }{ |
| 103 | { |
| 104 | name: "workspace", |
| 105 | provider: func(_ *testing.T, repo string, runner *gitcmd.Runner) *Provider { |
| 106 | return NewWorkspaceProvider(repo, runner) |
| 107 | }, |
| 108 | }, |
| 109 | { |
| 110 | name: "commit", |
| 111 | provider: func(t *testing.T, repo string, runner *gitcmd.Runner) *Provider { |
| 112 | runGitTest(t, repo, "add", "-A") |
| 113 | runGitTest(t, repo, "commit", "-q", "-m", "update non-ASCII file") |
| 114 | return NewCommitProvider(repo, "HEAD", runner) |
| 115 | }, |
| 116 | }, |
| 117 | { |
| 118 | name: "range", |
| 119 | provider: func(t *testing.T, repo string, runner *gitcmd.Runner) *Provider { |
| 120 | runGitTest(t, repo, "add", "-A") |
| 121 | runGitTest(t, repo, "commit", "-q", "-m", "update non-ASCII file") |
| 122 | return NewProvider(repo, "HEAD~1", "HEAD", runner) |
| 123 | }, |
| 124 | }, |
| 125 | } |
| 126 | |
| 127 | for _, tt := range tests { |
| 128 | t.Run(tt.name, func(t *testing.T) { |
| 129 | repo, relPath := initRepoWithNonASCIIChange(t) |
| 130 | provider := tt.provider(t, repo, gitcmd.New(0)) |
| 131 | |
| 132 | diffs, err := provider.GetDiff(context.Background()) |
| 133 | if err != nil { |
| 134 | t.Fatalf("GetDiff returned error: %v", err) |
| 135 | } |
| 136 | if len(diffs) != 1 { |
| 137 | t.Fatalf("got %d diffs, want 1: %+v", len(diffs), diffs) |
| 138 | } |
| 139 | if diffs[0].NewPath != relPath { |
| 140 | t.Errorf("NewPath = %q, want %q", diffs[0].NewPath, relPath) |
| 141 | } |
| 142 | if diffs[0].NewFileContent != "after\n" { |
| 143 | t.Errorf("NewFileContent = %q, want %q", diffs[0].NewFileContent, "after\n") |
| 144 | } |
| 145 | }) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | func TestWorkspaceDiffPreservesNonASCIIUntrackedPath(t *testing.T) { |
| 150 | repo, trackedPath := initRepoWithNonASCIIChange(t) |
nothing calls this directly
no test coverage detected