mirror of
https://github.com/restic/restic.git
synced 2026-09-15 08:47:57 +00:00
repository: make repo.Options configurable for test repos
This commit is contained in:
@@ -44,7 +44,7 @@ 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 backend.Backend, version uint) restic.Repository {
|
||||
func TestRepositoryWithBackend(t testing.TB, be backend.Backend, version uint, opts Options) restic.Repository {
|
||||
t.Helper()
|
||||
TestUseLowSecurityKDFParameters(t)
|
||||
restic.TestDisableCheckPolynomial(t)
|
||||
@@ -53,7 +53,7 @@ func TestRepositoryWithBackend(t testing.TB, be backend.Backend, version uint) r
|
||||
be = TestBackend(t)
|
||||
}
|
||||
|
||||
repo, err := New(be, Options{})
|
||||
repo, err := New(be, opts)
|
||||
if err != nil {
|
||||
t.Fatalf("TestRepository(): new repo failed: %v", err)
|
||||
}
|
||||
@@ -79,6 +79,7 @@ func TestRepository(t testing.TB) restic.Repository {
|
||||
func TestRepositoryWithVersion(t testing.TB, version uint) restic.Repository {
|
||||
t.Helper()
|
||||
dir := os.Getenv("RESTIC_TEST_REPO")
|
||||
opts := Options{}
|
||||
if dir != "" {
|
||||
_, err := os.Stat(dir)
|
||||
if err != nil {
|
||||
@@ -86,7 +87,7 @@ func TestRepositoryWithVersion(t testing.TB, version uint) restic.Repository {
|
||||
if err != nil {
|
||||
t.Fatalf("error creating local backend at %v: %v", dir, err)
|
||||
}
|
||||
return TestRepositoryWithBackend(t, be, version)
|
||||
return TestRepositoryWithBackend(t, be, version, opts)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
@@ -94,7 +95,7 @@ func TestRepositoryWithVersion(t testing.TB, version uint) restic.Repository {
|
||||
}
|
||||
}
|
||||
|
||||
return TestRepositoryWithBackend(t, nil, version)
|
||||
return TestRepositoryWithBackend(t, nil, version, opts)
|
||||
}
|
||||
|
||||
// TestOpenLocal opens a local repository.
|
||||
|
||||
Reference in New Issue
Block a user