(t *testing.T)
| 1345 | } |
| 1346 | |
| 1347 | func TestClientCheckoutBranch(t *testing.T) { |
| 1348 | tests := []struct { |
| 1349 | name string |
| 1350 | cmdExitStatus int |
| 1351 | cmdStdout string |
| 1352 | cmdStderr string |
| 1353 | wantCmdArgs string |
| 1354 | wantErrorMsg string |
| 1355 | }{ |
| 1356 | { |
| 1357 | name: "checkout branch", |
| 1358 | wantCmdArgs: `path/to/git checkout trunk`, |
| 1359 | }, |
| 1360 | { |
| 1361 | name: "git error", |
| 1362 | cmdExitStatus: 1, |
| 1363 | cmdStderr: "git error message", |
| 1364 | wantCmdArgs: `path/to/git checkout trunk`, |
| 1365 | wantErrorMsg: "failed to run git: git error message", |
| 1366 | }, |
| 1367 | } |
| 1368 | for _, tt := range tests { |
| 1369 | t.Run(tt.name, func(t *testing.T) { |
| 1370 | cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr) |
| 1371 | client := Client{ |
| 1372 | GitPath: "path/to/git", |
| 1373 | commandContext: cmdCtx, |
| 1374 | } |
| 1375 | err := client.CheckoutBranch(context.Background(), "trunk") |
| 1376 | assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " ")) |
| 1377 | if tt.wantErrorMsg == "" { |
| 1378 | assert.NoError(t, err) |
| 1379 | } else { |
| 1380 | assert.EqualError(t, err, tt.wantErrorMsg) |
| 1381 | } |
| 1382 | }) |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | func TestClientCheckoutNewBranch(t *testing.T) { |
| 1387 | tests := []struct { |
nothing calls this directly
no test coverage detected