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

Function TestIndexOpen

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

Source from the content-addressed store, hash-verified

241}
242
243func TestIndexOpen(t *testing.T) {
244 t.Parallel()
245 repo := createTestRepo(t)
246 defer cleanupTestRepo(t, repo)
247
248 path := repo.Workdir() + "/heyindex"
249
250 _, err := os.Stat(path)
251 if !os.IsNotExist(err) {
252 t.Fatal("new index file already exists")
253 }
254
255 idx, err := OpenIndex(path)
256 checkFatal(t, err)
257
258 if path != idx.Path() {
259 t.Fatalf("mismatched index paths, expected %v, got %v", path, idx.Path())
260 }
261
262 err = idx.Write()
263 checkFatal(t, err)
264
265 _, err = os.Stat(path)
266 if os.IsNotExist(err) {
267 t.Fatal("new index file did not get written")
268 }
269}
270
271func checkFatal(t *testing.T, err error) {
272 if err == nil {

Callers

nothing calls this directly

Calls 7

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
OpenIndexFunction · 0.85
checkFatalFunction · 0.85
WorkdirMethod · 0.80
PathMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…