(t *testing.T)
| 258 | } |
| 259 | |
| 260 | func TestClientSetRemoteResolution(t *testing.T) { |
| 261 | tests := []struct { |
| 262 | name string |
| 263 | cmdExitStatus int |
| 264 | cmdStdout string |
| 265 | cmdStderr string |
| 266 | wantCmdArgs string |
| 267 | wantErrorMsg string |
| 268 | }{ |
| 269 | { |
| 270 | name: "set remote resolution", |
| 271 | wantCmdArgs: `path/to/git config --add remote.origin.gh-resolved base`, |
| 272 | }, |
| 273 | { |
| 274 | name: "git error", |
| 275 | cmdExitStatus: 1, |
| 276 | cmdStderr: "git error message", |
| 277 | wantCmdArgs: `path/to/git config --add remote.origin.gh-resolved base`, |
| 278 | wantErrorMsg: "failed to run git: git error message", |
| 279 | }, |
| 280 | } |
| 281 | for _, tt := range tests { |
| 282 | t.Run(tt.name, func(t *testing.T) { |
| 283 | cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr) |
| 284 | client := Client{ |
| 285 | GitPath: "path/to/git", |
| 286 | commandContext: cmdCtx, |
| 287 | } |
| 288 | err := client.SetRemoteResolution(context.Background(), "origin", "base") |
| 289 | assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " ")) |
| 290 | if tt.wantErrorMsg == "" { |
| 291 | assert.NoError(t, err) |
| 292 | } else { |
| 293 | assert.EqualError(t, err, tt.wantErrorMsg) |
| 294 | } |
| 295 | }) |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | func TestClientCurrentBranch(t *testing.T) { |
| 300 | tests := []struct { |
nothing calls this directly
no test coverage detected