mock

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 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
	DeleteFn           func(ctx context.Context) error
	ConnectionsFn      func() uint
	LocationFn         func() string
	HasherFn           func() hash.Hash
	HasAtomicReplaceFn func() bool
}

Backend implements a mock backend.

func NewBackend

func NewBackend() *Backend

NewBackend returns new mock Backend instance

func (*Backend) Close

func (m *Backend) Close() error

Close the backend.

func (*Backend) Connections

func (m *Backend) Connections() uint

func (*Backend) Delete

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

Delete all data.

func (*Backend) HasAtomicReplace

func (m *Backend) HasAtomicReplace() bool

HasAtomicReplace returns whether Save() can atomically replace files

func (*Backend) Hasher

func (m *Backend) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

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.

Jump to

Keyboard shortcuts

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