repository: Remove empty cleanup functions in tests
TestRepository and its variants always returned no-op cleanup functions. If they ever do need to do cleanup, using testing.T.Cleanup is easier than passing these functions around.
This commit is contained in:
parent
f90bf84ba7
commit
c0b5ec55ab
19 changed files with 91 additions and 190 deletions
|
@ -33,8 +33,8 @@ func TestUseLowSecurityKDFParameters(t logger) {
|
|||
}
|
||||
|
||||
// TestBackend returns a fully configured in-memory backend.
|
||||
func TestBackend(t testing.TB) (be restic.Backend, cleanup func()) {
|
||||
return mem.New(), func() {}
|
||||
func TestBackend(t testing.TB) restic.Backend {
|
||||
return mem.New()
|
||||
}
|
||||
|
||||
const TestChunkerPol = chunker.Pol(0x3DA3358B4DC173)
|
||||
|
@ -42,14 +42,13 @@ const TestChunkerPol = chunker.Pol(0x3DA3358B4DC173)
|
|||
// TestRepositoryWithBackend returns a repository initialized with a test
|
||||
// password. If be is nil, an in-memory backend is used. A constant polynomial
|
||||
// is used for the chunker and low-security test parameters.
|
||||
func TestRepositoryWithBackend(t testing.TB, be restic.Backend, version uint) (r restic.Repository, cleanup func()) {
|
||||
func TestRepositoryWithBackend(t testing.TB, be restic.Backend, version uint) restic.Repository {
|
||||
t.Helper()
|
||||
TestUseLowSecurityKDFParameters(t)
|
||||
restic.TestDisableCheckPolynomial(t)
|
||||
|
||||
var beCleanup func()
|
||||
if be == nil {
|
||||
be, beCleanup = TestBackend(t)
|
||||
be = TestBackend(t)
|
||||
}
|
||||
|
||||
repo, err := New(be, Options{})
|
||||
|
@ -63,23 +62,19 @@ func TestRepositoryWithBackend(t testing.TB, be restic.Backend, version uint) (r
|
|||
t.Fatalf("TestRepository(): initialize repo failed: %v", err)
|
||||
}
|
||||
|
||||
return repo, func() {
|
||||
if beCleanup != nil {
|
||||
beCleanup()
|
||||
}
|
||||
}
|
||||
return repo
|
||||
}
|
||||
|
||||
// TestRepository returns a repository initialized with a test password on an
|
||||
// in-memory backend. When the environment variable RESTIC_TEST_REPO is set to
|
||||
// a non-existing directory, a local backend is created there and this is used
|
||||
// instead. The directory is not removed, but left there for inspection.
|
||||
func TestRepository(t testing.TB) (r restic.Repository, cleanup func()) {
|
||||
func TestRepository(t testing.TB) restic.Repository {
|
||||
t.Helper()
|
||||
return TestRepositoryWithVersion(t, 0)
|
||||
}
|
||||
|
||||
func TestRepositoryWithVersion(t testing.TB, version uint) (r restic.Repository, cleanup func()) {
|
||||
func TestRepositoryWithVersion(t testing.TB, version uint) restic.Repository {
|
||||
t.Helper()
|
||||
dir := os.Getenv("RESTIC_TEST_REPO")
|
||||
if dir != "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue