MCPcopy Create free account
hub / github.com/libgit2/git2go / TestBranchIteratorEach

Function TestBranchIteratorEach

branch_test.go:30–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestBranchIteratorEach(t *testing.T) {
31 t.Parallel()
32 repo := createTestRepo(t)
33 defer cleanupTestRepo(t, repo)
34
35 seedTestRepo(t, repo)
36
37 i, err := repo.NewBranchIterator(BranchLocal)
38 checkFatal(t, err)
39
40 var names []string
41 f := func(b *Branch, t BranchType) error {
42 name, err := b.Name()
43 if err != nil {
44 return err
45 }
46
47 names = append(names, name)
48 return nil
49 }
50
51 err = i.ForEach(f)
52 if err != nil && !IsErrorCode(err, ErrorCodeIterOver) {
53 t.Fatal(err)
54 }
55
56 if len(names) != 1 {
57 t.Fatalf("expect 1 branch, but it was %d\n", len(names))
58 }
59
60 if names[0] != "master" {
61 t.Fatalf("expect branch master, but it was %s\n", names[0])
62 }
63}

Callers

nothing calls this directly

Calls 8

ForEachMethod · 0.95
createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
checkFatalFunction · 0.85
IsErrorCodeFunction · 0.85
NewBranchIteratorMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…