MCPcopy Create free account
hub / github.com/cli/cli / TestClientHasLocalBranch

Function TestClientHasLocalBranch

git/client_test.go:1316–1349  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1314}
1315
1316func 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
1351func TestClientCheckoutBranch(t *testing.T) {
1352 tests := []struct {

Callers

nothing calls this directly

Calls 5

HasLocalBranchMethod · 0.95
createCommandContextFunction · 0.85
EqualMethod · 0.80
JoinMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected