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

Function TestTreeWalkStop

tree_test.go:114–137  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestTreeWalkStop(t *testing.T) {
115 t.Parallel()
116 repo, err := OpenRepository("testdata/TestGitRepository.git")
117 checkFatal(t, err)
118 treeID, err := NewOid("6020a3b8d5d636e549ccbd0c53e2764684bb3125")
119 checkFatal(t, err)
120
121 tree, err := repo.LookupTree(treeID)
122 checkFatal(t, err)
123
124 var callCount int
125 stopError := errors.New("stop")
126 err = tree.Walk(func(name string, entry *TreeEntry) error {
127 callCount++
128
129 return stopError
130 })
131 if err != stopError {
132 t.Fatalf("got error %v, want %v", err, stopError)
133 }
134 if callCount != 1 {
135 t.Fatalf("got called %v times, want %v", callCount, 1)
136 }
137}

Callers

nothing calls this directly

Calls 5

OpenRepositoryFunction · 0.85
checkFatalFunction · 0.85
NewOidFunction · 0.85
LookupTreeMethod · 0.80
WalkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…