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