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