aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/repo_open_repository.go
blob: cea721e0e175dde61b19db1702b63feb57816b19 (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
package testgit

import (
	"testing"

	"lindenii.org/go/furgit/repository"
)

// OpenRepository opens the repository and registers cleanup on the caller.
func (testRepo *TestRepo) OpenRepository(tb testing.TB) *repository.Repository {
	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
}