testing

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: ISC Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFiles

func GenerateFiles(t *testing.T, files []MockFile) string

func GenerateRepository

func GenerateRepository(t *testing.T, bufout *bytes.Buffer, buferr *bytes.Buffer, passphrase *[]byte) (*repository.Repository, *appcontext.AppContext)

func GenerateRepositoryWithoutConfig

func GenerateRepositoryWithoutConfig(t *testing.T, bufout *bytes.Buffer, buferr *bytes.Buffer, passphrase *[]byte) (*repository.Repository, *appcontext.AppContext)

func GenerateSnapshot

func GenerateSnapshot(t *testing.T, repo *repository.Repository, files []MockFile, opts ...TestingOptions) *snapshot.Snapshot

func NewConfiguration

func NewConfiguration(opts ...ConfigurationOptions) *storage.Configuration

func NewMockImporter

func NewMockImporter(appCtx context.Context, opts *connectors.Options, name string, config map[string]string) (importer.Importer, error)

func StartCached added in v1.1.1

func StartCached(t *testing.T, ctx *appcontext.AppContext)

StartCached runs the cached daemon in-process, listening on the cached.sock of the given context's CacheDir. The cached client connects to that socket before trying to spawn an external process, so commands relying on cached (sync, backup -check, ...) can be exercised from tests as long as the server is started before they execute.

Types

type ConfigurationOptions

type ConfigurationOptions func(o *storage.Configuration)

func WithConfigurationCompression

func WithConfigurationCompression(compression *compression.Configuration) ConfigurationOptions

type MockBackend

type MockBackend struct {
	// contains filtered or unexported fields
}

MockBackend implements the Backend interface for testing purposes

func NewMockBackend

func NewMockBackend(storeConfig map[string]string) *MockBackend

func (*MockBackend) Close

func (mb *MockBackend) Close(ctx context.Context) error

func (*MockBackend) Create

func (mb *MockBackend) Create(ctx context.Context, configuration []byte) error

func (*MockBackend) Delete added in v1.1.0

func (mb *MockBackend) Delete(ctx context.Context, res storage.StorageResource, mac objects.MAC) error

func (*MockBackend) Flags added in v1.1.0

func (mb *MockBackend) Flags() location.Flags

func (*MockBackend) Get added in v1.1.0

func (*MockBackend) List added in v1.1.0

func (*MockBackend) Mode

func (*MockBackend) Open

func (mb *MockBackend) Open(ctx context.Context) ([]byte, error)

func (*MockBackend) Origin added in v1.1.0

func (mb *MockBackend) Origin() string

func (*MockBackend) Ping added in v1.1.0

func (mb *MockBackend) Ping(ctx context.Context) error

func (*MockBackend) Put added in v1.1.0

func (*MockBackend) Root added in v1.1.0

func (mb *MockBackend) Root() string

func (*MockBackend) Size

func (mb *MockBackend) Size(ctx context.Context) (int64, error)

func (*MockBackend) Type added in v1.1.0

func (mb *MockBackend) Type() string

type MockFTPServer added in v1.0.3

type MockFTPServer struct {
	Addr string

	Files map[string][]byte
	Dirs  map[string]bool
	// contains filtered or unexported fields
}

func NewMockFTPServer added in v1.0.3

func NewMockFTPServer() (*MockFTPServer, error)

func (*MockFTPServer) Close added in v1.0.3

func (s *MockFTPServer) Close()

func (*MockFTPServer) SetAuth added in v1.0.3

func (s *MockFTPServer) SetAuth(user, pass string)

type MockFile

type MockFile struct {
	Path    string
	IsDir   bool
	Mode    os.FileMode
	Content []byte
}

func NewMockDir

func NewMockDir(path string) MockFile

func NewMockFile

func NewMockFile(path string, mode os.FileMode, content string) MockFile

func (*MockFile) ScanResult

func (m *MockFile) ScanResult() *connectors.Record

type MockImporter

type MockImporter struct {
	// contains filtered or unexported fields
}

func (*MockImporter) Close

func (p *MockImporter) Close(ctx context.Context) error

func (*MockImporter) Flags added in v1.1.0

func (p *MockImporter) Flags() location.Flags

func (*MockImporter) Import added in v1.1.0

func (p *MockImporter) Import(ctx context.Context, records chan<- *connectors.Record, results <-chan *connectors.Result) error

func (*MockImporter) Origin

func (p *MockImporter) Origin() string

func (*MockImporter) Ping added in v1.1.0

func (p *MockImporter) Ping(ctx context.Context) error

func (*MockImporter) Root

func (p *MockImporter) Root() string

func (*MockImporter) SetFiles

func (p *MockImporter) SetFiles(files []MockFile)

func (*MockImporter) SetGenerator

func (p *MockImporter) SetGenerator(gen func(chan<- *connectors.Record))

func (*MockImporter) Type

func (p *MockImporter) Type() string

type TestingOptions

type TestingOptions func(o *testingOptions)

func WithExcludes added in v1.1.0

func WithExcludes(excludes []string) TestingOptions

func WithGenerator

func WithGenerator(gen func(chan<- *connectors.Record)) TestingOptions

func WithName

func WithName(name string) TestingOptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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