(t *testing.T)
| 1314 | } |
| 1315 | |
| 1316 | func TestClientHasLocalBranch(t *testing.T) { |
| 1317 | tests := []struct { |
| 1318 | name string |
| 1319 | cmdExitStatus int |
| 1320 | cmdStdout string |
| 1321 | cmdStderr string |
| 1322 | wantCmdArgs string |
| 1323 | wantOut bool |
| 1324 | }{ |
| 1325 | { |
| 1326 | name: "has local branch", |
| 1327 | wantCmdArgs: `path/to/git rev-parse --verify refs/heads/trunk`, |
| 1328 | wantOut: true, |
| 1329 | }, |
| 1330 | { |
| 1331 | name: "does not have local branch", |
| 1332 | cmdExitStatus: 1, |
| 1333 | wantCmdArgs: `path/to/git rev-parse --verify refs/heads/trunk`, |
| 1334 | wantOut: false, |
| 1335 | }, |
| 1336 | } |
| 1337 | for _, tt := range tests { |
| 1338 | t.Run(tt.name, func(t *testing.T) { |
| 1339 | cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr) |
| 1340 | client := Client{ |
| 1341 | GitPath: "path/to/git", |
| 1342 | commandContext: cmdCtx, |
| 1343 | } |
| 1344 | out := client.HasLocalBranch(context.Background(), "trunk") |
| 1345 | assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " ")) |
| 1346 | assert.Equal(t, out, tt.wantOut) |
| 1347 | }) |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | func TestClientCheckoutBranch(t *testing.T) { |
| 1352 | tests := []struct { |
nothing calls this directly
no test coverage detected