(t *testing.T)
| 219 | } |
| 220 | |
| 221 | func TestClientUpdateRemoteURL(t *testing.T) { |
| 222 | tests := []struct { |
| 223 | name string |
| 224 | cmdExitStatus int |
| 225 | cmdStdout string |
| 226 | cmdStderr string |
| 227 | wantCmdArgs string |
| 228 | wantErrorMsg string |
| 229 | }{ |
| 230 | { |
| 231 | name: "update remote url", |
| 232 | wantCmdArgs: `path/to/git remote set-url test https://test.com`, |
| 233 | }, |
| 234 | { |
| 235 | name: "git error", |
| 236 | cmdExitStatus: 1, |
| 237 | cmdStderr: "git error message", |
| 238 | wantCmdArgs: `path/to/git remote set-url test https://test.com`, |
| 239 | wantErrorMsg: "failed to run git: git error message", |
| 240 | }, |
| 241 | } |
| 242 | for _, tt := range tests { |
| 243 | t.Run(tt.name, func(t *testing.T) { |
| 244 | cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr) |
| 245 | client := Client{ |
| 246 | GitPath: "path/to/git", |
| 247 | commandContext: cmdCtx, |
| 248 | } |
| 249 | err := client.UpdateRemoteURL(context.Background(), "test", "https://test.com") |
| 250 | assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " ")) |
| 251 | if tt.wantErrorMsg == "" { |
| 252 | assert.NoError(t, err) |
| 253 | } else { |
| 254 | assert.EqualError(t, err, tt.wantErrorMsg) |
| 255 | } |
| 256 | }) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | func TestClientSetRemoteResolution(t *testing.T) { |
| 261 | tests := []struct { |
nothing calls this directly
no test coverage detected