mock

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2018 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	CloseFn      func() error
	IsNotExistFn func(err error) bool
	SaveFn       func(ctx context.Context, h restic.Handle, rd restic.RewindReader) error
	OpenReaderFn func(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error)
	StatFn       func(ctx context.Context, h restic.Handle) (restic.FileInfo, error)
	ListFn       func(ctx context.Context, t restic.FileType, fn func(restic.FileInfo) error) error
	RemoveFn     func(ctx context.Context, h restic.Handle) error
	TestFn       func(ctx context.Context, h restic.Handle) (bool, error)
	DeleteFn     func(ctx context.Context) error
	LocationFn   func() string
}

Backend implements a mock backend.

func NewBackend added in v0.8.3

func NewBackend() *Backend

NewBackend returns new mock Backend instance

func (*Backend) Close

func (m *Backend) Close() error

Close the backend.

func (*Backend) Delete

func (m *Backend) Delete(ctx context.Context) error

Delete all data.

func (*Backend) IsNotExist

func (m *Backend) IsNotExist(err error) bool

IsNotExist returns true if the error is caused by a missing file.

func (*Backend) List

func (m *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.FileInfo) error) error

List items of type t.

func (*Backend) Load

func (m *Backend) Load(ctx context.Context, h restic.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*Backend) Location

func (m *Backend) Location() string

Location returns a location string.

func (*Backend) Remove

func (m *Backend) Remove(ctx context.Context, h restic.Handle) error

Remove data from the backend.

func (*Backend) Save

Save data in the backend.

func (*Backend) Stat

func (m *Backend) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error)

Stat an object in the backend.

func (*Backend) Test

func (m *Backend) Test(ctx context.Context, h restic.Handle) (bool, error)

Test for the existence of a specific item.

type Repository

type Repository struct {
	BackendFn func() restic.Backend

	KeyFn func() *crypto.Key

	SetIndexFn func(restic.Index) error

	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)
}

Repository implements a mock Repository.

func (Repository) Backend

func (repo Repository) Backend() restic.Backend

Backend is a stub method.

func (Repository) Config

func (repo Repository) Config() restic.Config

Config is a stub method.

func (Repository) Flush

func (repo Repository) Flush() error

Flush is a stub method.

func (Repository) Index

func (repo Repository) Index() restic.Index

Index is a stub method.

func (Repository) Key

func (repo Repository) Key() *crypto.Key

Key is a stub method.

func (Repository) List

func (repo Repository) List(t restic.FileType, done <-chan struct{}) <-chan restic.ID

List is a stub method.

func (Repository) ListPack

func (repo Repository) ListPack(id restic.ID) ([]restic.Blob, int64, error)

ListPack is a stub method.

func (Repository) LoadAndDecrypt

func (repo Repository) LoadAndDecrypt(t restic.FileType, id restic.ID) ([]byte, error)

LoadAndDecrypt is a stub method.

func (Repository) LoadBlob

func (repo Repository) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error)

LoadBlob is a stub method.

func (Repository) LoadIndex

func (repo Repository) LoadIndex() error

LoadIndex is a stub method.

func (Repository) LoadJSONUnpacked

func (repo Repository) LoadJSONUnpacked(t restic.FileType, id restic.ID, item interface{}) error

LoadJSONUnpacked is a stub method.

func (Repository) LoadTree

func (repo Repository) LoadTree(id restic.ID) (*restic.Tree, error)

LoadTree is a stub method.

func (Repository) LookupBlobSize

func (repo Repository) LookupBlobSize(id restic.ID, t restic.BlobType) (uint, error)

LookupBlobSize is a stub method.

func (Repository) SaveBlob

func (repo Repository) SaveBlob(t restic.BlobType, buf []byte, id restic.ID) (restic.ID, error)

SaveBlob is a stub method.

func (Repository) SaveFullIndex

func (repo Repository) SaveFullIndex() error

SaveFullIndex is a stub method.

func (Repository) SaveIndex

func (repo Repository) SaveIndex() error

SaveIndex is a stub method.

func (Repository) SaveJSONUnpacked

func (repo Repository) SaveJSONUnpacked(t restic.FileType, item interface{}) (restic.ID, error)

SaveJSONUnpacked is a stub method.

func (Repository) SaveTree

func (repo Repository) SaveTree(t *restic.Tree) (restic.ID, error)

SaveTree is a stub method.

func (Repository) SaveUnpacked

func (repo Repository) SaveUnpacked(t restic.FileType, buf []byte) (restic.ID, error)

SaveUnpacked is a stub method.

func (Repository) SetIndex

func (repo Repository) SetIndex(idx restic.Index) error

SetIndex is a stub method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL