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

Function TestClientHasLocalBranch

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

Source from the content-addressed store, hash-verified

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