mirror of
https://github.com/restic/restic.git
synced 2026-06-27 02:54:19 +00:00
ensure reliable cleanup of test repository (#21880)
This commit is contained in:
committed by
Michael Eischer
parent
cb24c4f566
commit
a3fa3eb182
@@ -15,8 +15,7 @@ import (
|
||||
var repoFixture = filepath.Join("..", "testdata", "test-repo.tar.gz")
|
||||
|
||||
func TestRepositoryForAllIndexes(t *testing.T) {
|
||||
repo, _, cleanup := repository.TestFromFixture(t, repoFixture)
|
||||
defer cleanup()
|
||||
repo, _ := repository.TestFromFixture(t, repoFixture)
|
||||
|
||||
expectedIndexIDs := restic.NewIDSet()
|
||||
rtest.OK(t, repo.List(context.TODO(), restic.IndexFile, func(id restic.ID, size int64) error {
|
||||
|
||||
@@ -319,8 +319,7 @@ func benchmarkLoadUnpacked(b *testing.B, version uint) {
|
||||
var repoFixture = filepath.Join("testdata", "test-repo.tar.gz")
|
||||
|
||||
func TestRepositoryLoadIndex(t *testing.T) {
|
||||
repo, _, cleanup := repository.TestFromFixture(t, repoFixture)
|
||||
defer cleanup()
|
||||
repo, _ := repository.TestFromFixture(t, repoFixture)
|
||||
|
||||
rtest.OK(t, repo.LoadIndex(context.TODO(), nil))
|
||||
}
|
||||
@@ -373,8 +372,7 @@ func (be *damageOnceBackend) Load(ctx context.Context, h backend.Handle, length
|
||||
}
|
||||
|
||||
func TestRepositoryLoadUnpackedRetryBroken(t *testing.T) {
|
||||
repodir, cleanup := rtest.Env(t, repoFixture)
|
||||
defer cleanup()
|
||||
repodir := rtest.Env(t, repoFixture)
|
||||
|
||||
be, err := local.Open(context.TODO(), local.Config{Path: repodir, Connections: 2}, t.Logf)
|
||||
rtest.OK(t, err)
|
||||
|
||||
@@ -105,11 +105,11 @@ func TestRepositoryWithVersion(t testing.TB, version uint) (*Repository, restic.
|
||||
return repo, &internalRepository{repo}, be
|
||||
}
|
||||
|
||||
func TestFromFixture(t testing.TB, repoFixture string) (*Repository, backend.Backend, func()) {
|
||||
repodir, cleanup := test.Env(t, repoFixture)
|
||||
func TestFromFixture(t testing.TB, repoFixture string) (*Repository, backend.Backend) {
|
||||
repodir := test.Env(t, repoFixture)
|
||||
repo, be := TestOpenLocal(t, repodir)
|
||||
|
||||
return repo, be, cleanup
|
||||
return repo, be
|
||||
}
|
||||
|
||||
// TestOpenLocal opens a local repository.
|
||||
|
||||
Reference in New Issue
Block a user