2016-01-23 13:19:26 -05:00
|
|
|
package mem_test
|
2016-01-23 11:42:26 -05:00
|
|
|
|
|
|
|
|
import (
|
2016-08-31 16:51:35 -04:00
|
|
|
"restic"
|
|
|
|
|
|
2016-09-01 16:17:37 -04:00
|
|
|
"restic/errors"
|
2016-01-23 11:42:26 -05:00
|
|
|
|
2016-02-14 09:29:28 -05:00
|
|
|
"restic/backend/mem"
|
|
|
|
|
"restic/backend/test"
|
2016-01-23 11:42:26 -05:00
|
|
|
)
|
|
|
|
|
|
2016-08-31 16:51:35 -04:00
|
|
|
var be restic.Backend
|
2016-01-23 11:42:26 -05:00
|
|
|
|
2016-01-23 13:19:26 -05:00
|
|
|
//go:generate go run ../test/generate_backend_tests.go
|
2016-01-23 11:42:26 -05:00
|
|
|
|
|
|
|
|
func init() {
|
2016-08-31 16:51:35 -04:00
|
|
|
test.CreateFn = func() (restic.Backend, error) {
|
2016-01-23 11:42:26 -05:00
|
|
|
if be != nil {
|
|
|
|
|
return nil, errors.New("temporary memory backend dir already exists")
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 13:19:26 -05:00
|
|
|
be = mem.New()
|
2016-01-23 11:42:26 -05:00
|
|
|
|
|
|
|
|
return be, nil
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-31 16:51:35 -04:00
|
|
|
test.OpenFn = func() (restic.Backend, error) {
|
2016-01-23 11:42:26 -05:00
|
|
|
if be == nil {
|
|
|
|
|
return nil, errors.New("repository not initialized")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return be, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test.CleanupFn = func() error {
|
|
|
|
|
be = nil
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
}
|