mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
Add streaming functions to mockBackend
This commit is contained in:
parent
89bf88df7a
commit
6c68150e45
1 changed files with 17 additions and 6 deletions
|
@ -2,6 +2,7 @@ package backend_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -47,12 +48,14 @@ func str2id(s string) backend.ID {
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockBackend struct {
|
type mockBackend struct {
|
||||||
list func(backend.Type) (backend.IDs, error)
|
list func(backend.Type) (backend.IDs, error)
|
||||||
get func(backend.Type, backend.ID) ([]byte, error)
|
get func(backend.Type, backend.ID) ([]byte, error)
|
||||||
create func(backend.Type, []byte) (backend.ID, error)
|
getReader func(backend.Type, backend.ID) (io.ReadCloser, error)
|
||||||
test func(backend.Type, backend.ID) (bool, error)
|
create func(backend.Type, []byte) (backend.ID, error)
|
||||||
remove func(backend.Type, backend.ID) error
|
createFrom func(backend.Type, io.Reader) (backend.ID, error)
|
||||||
close func() 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) (backend.IDs, error) {
|
func (m mockBackend) List(t backend.Type) (backend.IDs, error) {
|
||||||
|
@ -63,10 +66,18 @@ func (m mockBackend) Get(t backend.Type, id backend.ID) ([]byte, error) {
|
||||||
return m.get(t, id)
|
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) {
|
func (m mockBackend) Create(t backend.Type, data []byte) (backend.ID, error) {
|
||||||
return m.create(t, data)
|
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) {
|
func (m mockBackend) Test(t backend.Type, id backend.ID) (bool, error) {
|
||||||
return m.test(t, id)
|
return m.test(t, id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue