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

Function TestIndexRemoveDirectory

index_test.go:128–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestIndexRemoveDirectory(t *testing.T) {
129 repo := createTestRepo(t)
130 defer cleanupTestRepo(t, repo)
131
132 odb, err := repo.Odb()
133 checkFatal(t, err)
134
135 blobID, err := odb.Write([]byte("fou\n"), ObjectBlob)
136 checkFatal(t, err)
137
138 idx, err := NewIndex()
139 checkFatal(t, err)
140
141 entryCount := idx.EntryCount()
142 if entryCount != 0 {
143 t.Fatal("Index should count 0 entry")
144 }
145
146 entry := IndexEntry{
147 Path: "path/to/LISEZ_MOI",
148 Id: blobID,
149 Mode: FilemodeBlob,
150 }
151
152 err = idx.Add(&entry)
153 checkFatal(t, err)
154
155 entryCount = idx.EntryCount()
156 if entryCount != 1 {
157 t.Fatal("Index should count 1 entry")
158 }
159
160 err = idx.RemoveDirectory("path", 0)
161
162 entryCount = idx.EntryCount()
163 if entryCount != 0 {
164 t.Fatal("Index should count 0 entry")
165 }
166}
167
168func TestIndexAddFromBuffer(t *testing.T) {
169 t.Parallel()

Callers

nothing calls this directly

Calls 9

EntryCountMethod · 0.95
AddMethod · 0.95
RemoveDirectoryMethod · 0.95
createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
checkFatalFunction · 0.85
NewIndexFunction · 0.85
OdbMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…