mirror of
https://github.com/octoleo/restic.git
synced 2024-12-28 04:56:04 +00:00
Add streaming functions to mockBackend
This commit is contained in:
parent
89bf88df7a
commit
6c68150e45
@ -2,6 +2,7 @@ package backend_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -49,7 +50,9 @@ 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)
|
||||||
|
getReader func(backend.Type, backend.ID) (io.ReadCloser, error)
|
||||||
create func(backend.Type, []byte) (backend.ID, 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)
|
test func(backend.Type, backend.ID) (bool, error)
|
||||||
remove func(backend.Type, backend.ID) error
|
remove func(backend.Type, backend.ID) error
|
||||||
close func() error
|
close func() 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 New Issue
Block a user