aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/repo_open_object_store.go
blob: 066fd9d4b0aa9e812cc9c14e3f874072496263ab (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package testgit

import (
	"testing"

	objectstore "lindenii.org/go/furgit/object/store"
	"lindenii.org/go/furgit/repository"
)

// OpenObjectStore opens the repository object store and registers cleanup on
// the caller.
//
//nolint:ireturn
func (testRepo *TestRepo) OpenObjectStore(tb testing.TB) objectstore.Reader {
	tb.Helper()

	root := testRepo.OpenGitRoot(tb)

	repo, err := repository.Open(root)
	if err != nil {
		tb.Fatalf("repository.Open: %v", err)
	}

	tb.Cleanup(func() {
		_ = repo.Close()
	})

	return repo.ObjectStore()
}