2016-01-23 18:19:26 +00:00
|
|
|
package mem_test
|
2016-01-23 16:42:26 +00:00
|
|
|
|
|
|
|
import (
|
2016-08-21 15:46:23 +00:00
|
|
|
"github.com/pkg/errors"
|
2016-01-23 16:42:26 +00:00
|
|
|
|
2016-02-14 14:29:28 +00:00
|
|
|
"restic/backend"
|
|
|
|
"restic/backend/mem"
|
|
|
|
"restic/backend/test"
|
2016-01-23 16:42:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var be backend.Backend
|
|
|
|
|
2016-01-23 18:19:26 +00:00
|
|
|
//go:generate go run ../test/generate_backend_tests.go
|
2016-01-23 16:42:26 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
test.CreateFn = func() (backend.Backend, error) {
|
|
|
|
if be != nil {
|
|
|
|
return nil, errors.New("temporary memory backend dir already exists")
|
|
|
|
}
|
|
|
|
|
2016-01-23 18:19:26 +00:00
|
|
|
be = mem.New()
|
2016-01-23 16:42:26 +00:00
|
|
|
|
|
|
|
return be, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
test.OpenFn = func() (backend.Backend, error) {
|
|
|
|
if be == nil {
|
|
|
|
return nil, errors.New("repository not initialized")
|
|
|
|
}
|
|
|
|
|
|
|
|
return be, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
test.CleanupFn = func() error {
|
|
|
|
be = nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|