2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00

lock: use mem backend for locking tests

This hopefully fixes the timing related test failures which appear to be
caused by very slow fsync calls.
This commit is contained in:
Michael Eischer 2023-07-09 15:18:16 +02:00
parent 6a436d731d
commit 399f8e84a1

View File

@ -8,6 +8,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/restic/restic/internal/backend/location"
"github.com/restic/restic/internal/backend/mem"
"github.com/restic/restic/internal/repository" "github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/restic" "github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/test" "github.com/restic/restic/internal/test"
@ -15,6 +17,12 @@ import (
func openLockTestRepo(t *testing.T, wrapper backendWrapper) (*repository.Repository, func(), *testEnvironment) { func openLockTestRepo(t *testing.T, wrapper backendWrapper) (*repository.Repository, func(), *testEnvironment) {
env, cleanup := withTestEnvironment(t) env, cleanup := withTestEnvironment(t)
reg := location.NewRegistry()
reg.Register(mem.NewFactory())
env.gopts.backends = reg
env.gopts.Repo = "mem:"
if wrapper != nil { if wrapper != nil {
env.gopts.backendTestHook = wrapper env.gopts.backendTestHook = wrapper
} }