forked from TrueCloudLab/restic
Refactor mockBackend for test
This commit is contained in:
parent
b86786aec9
commit
2abda75404
1 changed files with 1 additions and 37 deletions
|
@ -2,7 +2,6 @@ package backend_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
@ -49,47 +48,12 @@ func str2id(s string) backend.ID {
|
|||
|
||||
type mockBackend struct {
|
||||
list func(backend.Type, <-chan struct{}) <-chan string
|
||||
get func(backend.Type, backend.ID) ([]byte, error)
|
||||
getReader func(backend.Type, backend.ID) (io.ReadCloser, error)
|
||||
create func(backend.Type, []byte) (backend.ID, error)
|
||||
createFrom func(backend.Type, io.Reader) (backend.ID, error)
|
||||
test func(backend.Type, backend.ID) (bool, error)
|
||||
remove func(backend.Type, backend.ID) error
|
||||
close func() error
|
||||
}
|
||||
|
||||
func (m mockBackend) List(t backend.Type, done <-chan struct{}) <-chan string {
|
||||
return m.list(t, done)
|
||||
}
|
||||
|
||||
func (m mockBackend) Get(t backend.Type, id backend.ID) ([]byte, error) {
|
||||
return m.get(t, id)
|
||||
}
|
||||
|
||||
func (m mockBackend) GetReader(t backend.Type, id backend.ID) (io.ReadCloser, error) {
|
||||
return m.getReader(t, id)
|
||||
}
|
||||
|
||||
func (m mockBackend) Create(t backend.Type, data []byte) (backend.ID, error) {
|
||||
return m.create(t, data)
|
||||
}
|
||||
|
||||
func (m mockBackend) CreateFrom(t backend.Type, r io.Reader) (backend.ID, error) {
|
||||
return m.createFrom(t, r)
|
||||
}
|
||||
|
||||
func (m mockBackend) Test(t backend.Type, id backend.ID) (bool, error) {
|
||||
return m.test(t, id)
|
||||
}
|
||||
|
||||
func (m mockBackend) Remove(t backend.Type, id backend.ID) error {
|
||||
return m.remove(t, id)
|
||||
}
|
||||
|
||||
func (m mockBackend) Close() error {
|
||||
return m.close()
|
||||
}
|
||||
|
||||
var samples = backend.IDs{
|
||||
str2id("20bdc1402a6fc9b633aaffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
str2id("20bdc1402a6fc9b633ccd578c4a92d0f4ef1a457fa2e16c596bc73fb409d6cc0"),
|
||||
|
|
Loading…
Reference in a new issue