2016-09-04 10:52:43 +00:00
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
2017-07-23 12:21:03 +00:00
|
|
|
"github.com/restic/restic/internal/crypto"
|
2017-07-24 15:42:25 +00:00
|
|
|
"github.com/restic/restic/internal/restic"
|
2016-09-04 10:52:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Repository implements a mock Repository.
|
|
|
|
type Repository struct {
|
2016-09-04 11:18:25 +00:00
|
|
|
BackendFn func() restic.Backend
|
2016-09-04 10:52:43 +00:00
|
|
|
|
|
|
|
KeyFn func() *crypto.Key
|
|
|
|
|
2018-03-31 08:02:09 +00:00
|
|
|
SetIndexFn func(restic.Index) error
|
2016-09-04 10:52:43 +00:00
|
|
|
|
|
|
|
IndexFn func() restic.Index
|
|
|
|
SaveFullIndexFn func() error
|
|
|
|
SaveIndexFn func() error
|
|
|
|
LoadIndexFn func() error
|
|
|
|
|
|
|
|
ConfigFn func() restic.Config
|
|
|
|
|
|
|
|
LookupBlobSizeFn func(restic.ID, restic.BlobType) (uint, error)
|
|
|
|
|
|
|
|
ListFn func(restic.FileType, <-chan struct{}) <-chan restic.ID
|
|
|
|
ListPackFn func(restic.ID) ([]restic.Blob, int64, error)
|
|
|
|
|
|
|
|
FlushFn func() error
|
|
|
|
|
|
|
|
SaveUnpackedFn func(restic.FileType, []byte) (restic.ID, error)
|
|
|
|
SaveJSONUnpackedFn func(restic.FileType, interface{}) (restic.ID, error)
|
|
|
|
|
|
|
|
LoadJSONUnpackedFn func(restic.FileType, restic.ID, interface{}) error
|
|
|
|
LoadAndDecryptFn func(restic.FileType, restic.ID) ([]byte, error)
|
|
|
|
|
|
|
|
LoadBlobFn func(restic.BlobType, restic.ID, []byte) (int, error)
|
|
|
|
SaveBlobFn func(restic.BlobType, []byte, restic.ID) (restic.ID, error)
|
|
|
|
|
|
|
|
LoadTreeFn func(restic.ID) (*restic.Tree, error)
|
|
|
|
SaveTreeFn func(t *restic.Tree) (restic.ID, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Backend is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) Backend() restic.Backend {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.BackendFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Key is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) Key() *crypto.Key {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.KeyFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIndex is a stub method.
|
2018-03-31 08:02:09 +00:00
|
|
|
func (repo Repository) SetIndex(idx restic.Index) error {
|
|
|
|
return repo.SetIndexFn(idx)
|
2016-09-04 10:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Index is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) Index() restic.Index {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.IndexFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveFullIndex is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) SaveFullIndex() error {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.SaveFullIndexFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveIndex is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) SaveIndex() error {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.SaveIndexFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadIndex is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) LoadIndex() error {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.LoadIndexFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Config is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) Config() restic.Config {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.ConfigFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// LookupBlobSize is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) LookupBlobSize(id restic.ID, t restic.BlobType) (uint, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.LookupBlobSizeFn(id, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
// List is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) List(t restic.FileType, done <-chan struct{}) <-chan restic.ID {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.ListFn(t, done)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListPack is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) ListPack(id restic.ID) ([]restic.Blob, int64, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.ListPackFn(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flush is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) Flush() error {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.FlushFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveUnpacked is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) SaveUnpacked(t restic.FileType, buf []byte) (restic.ID, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.SaveUnpackedFn(t, buf)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveJSONUnpacked is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) SaveJSONUnpacked(t restic.FileType, item interface{}) (restic.ID, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.SaveJSONUnpackedFn(t, item)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadJSONUnpacked is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) LoadJSONUnpacked(t restic.FileType, id restic.ID, item interface{}) error {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.LoadJSONUnpackedFn(t, id, item)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadAndDecrypt is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) LoadAndDecrypt(t restic.FileType, id restic.ID) ([]byte, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.LoadAndDecryptFn(t, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadBlob is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.LoadBlobFn(t, id, buf)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveBlob is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) SaveBlob(t restic.BlobType, buf []byte, id restic.ID) (restic.ID, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.SaveBlobFn(t, buf, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadTree is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) LoadTree(id restic.ID) (*restic.Tree, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.LoadTreeFn(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveTree is a stub method.
|
2016-09-04 11:18:25 +00:00
|
|
|
func (repo Repository) SaveTree(t *restic.Tree) (restic.ID, error) {
|
2016-09-04 10:52:43 +00:00
|
|
|
return repo.SaveTreeFn(t)
|
|
|
|
}
|