MCPcopy
hub / github.com/cli/cli / TestClientHasLocalBranch

Function TestClientHasLocalBranch

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

Source from the content-addressed store, hash-verified

1310}
1311
1312func 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
1347func TestClientCheckoutBranch(t *testing.T) {
1348 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