testing

package
v1.0.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: ISC Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateContext

func GenerateContext(t *testing.T, bufout *bytes.Buffer, buferr *bytes.Buffer) *kcontext.KContext

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

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 NewMockExporter

func NewMockExporter(appCtx context.Context, opt *exporter.Options, name string, config map[string]string) (exporter.Exporter, error)

func NewMockImporter

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

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() error

func (*MockBackend) Create

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

func (*MockBackend) DeleteLock

func (mb *MockBackend) DeleteLock(lockID objects.MAC) error

func (*MockBackend) DeletePackfile

func (mb *MockBackend) DeletePackfile(MAC objects.MAC) error

func (*MockBackend) DeleteState

func (mb *MockBackend) DeleteState(MAC objects.MAC) error

func (*MockBackend) GetLock

func (mb *MockBackend) GetLock(lockID objects.MAC) (io.Reader, error)

func (*MockBackend) GetLocks

func (mb *MockBackend) GetLocks() ([]objects.MAC, error)

Locks

func (*MockBackend) GetPackfile

func (mb *MockBackend) GetPackfile(MAC objects.MAC) (io.Reader, error)

func (*MockBackend) GetPackfileBlob

func (mb *MockBackend) GetPackfileBlob(MAC objects.MAC, offset uint64, length uint32) (io.Reader, error)

func (*MockBackend) GetPackfiles

func (mb *MockBackend) GetPackfiles() ([]objects.MAC, error)

func (*MockBackend) GetState

func (mb *MockBackend) GetState(MAC objects.MAC) (io.Reader, error)

func (*MockBackend) GetStates

func (mb *MockBackend) GetStates() ([]objects.MAC, error)

func (*MockBackend) Location

func (mb *MockBackend) Location() string

func (*MockBackend) Mode

func (mb *MockBackend) Mode() storage.Mode

func (*MockBackend) Open

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

func (*MockBackend) PutLock

func (mb *MockBackend) PutLock(lockID objects.MAC, rd io.Reader) (int64, error)

func (*MockBackend) PutPackfile

func (mb *MockBackend) PutPackfile(MAC objects.MAC, rd io.Reader) (int64, error)

func (*MockBackend) PutState

func (mb *MockBackend) PutState(MAC objects.MAC, rd io.Reader) (int64, error)

func (*MockBackend) Size

func (mb *MockBackend) Size() int64

type MockClassifierBackend

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

func (*MockClassifierBackend) Close

func (m *MockClassifierBackend) Close() error

func (*MockClassifierBackend) Processor

type MockExporter

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

func (*MockExporter) Close

func (e *MockExporter) Close() error

func (*MockExporter) CreateDirectory

func (e *MockExporter) CreateDirectory(pathname string) error

func (*MockExporter) Files

func (e *MockExporter) Files() map[string][]byte

func (*MockExporter) Root

func (e *MockExporter) Root() string

func (*MockExporter) SetPermissions

func (e *MockExporter) SetPermissions(pathname string, fileinfo *objects.FileInfo) error

func (*MockExporter) StoreFile

func (e *MockExporter) StoreFile(pathname string, fp io.Reader, size int64) error

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() *importer.ScanResult

type MockImporter

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

func (*MockImporter) Close

func (p *MockImporter) Close() error

func (*MockImporter) Origin

func (p *MockImporter) Origin() string

func (*MockImporter) Root

func (p *MockImporter) Root() string

func (*MockImporter) Scan

func (p *MockImporter) Scan() (<-chan *importer.ScanResult, error)

func (*MockImporter) SetFiles

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

func (*MockImporter) SetGenerator

func (p *MockImporter) SetGenerator(gen func(chan<- *importer.ScanResult))

func (*MockImporter) Type

func (p *MockImporter) Type() string

type MockProcessorBackend

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

func (*MockProcessorBackend) Directory

func (m *MockProcessorBackend) Directory(dirEntry *vfs.Entry) []string

func (*MockProcessorBackend) File

func (m *MockProcessorBackend) File(fileEntry *vfs.Entry) []string

func (*MockProcessorBackend) Finalize

func (m *MockProcessorBackend) Finalize() []string

func (*MockProcessorBackend) Name

func (m *MockProcessorBackend) Name() string

func (*MockProcessorBackend) Write

func (m *MockProcessorBackend) Write(buf []byte) bool

type MockSFTPServer

type MockSFTPServer struct {
	Addr string

	KeyFile string
	// contains filtered or unexported fields
}

MockSFTPServer implements a simple SFTP server for testing

func NewMockSFTPServer

func NewMockSFTPServer(t *testing.T) (*MockSFTPServer, error)

func (*MockSFTPServer) Close

func (s *MockSFTPServer) Close()

type TestingOptions

type TestingOptions func(o *testingOptions)

func WithGenerator

func WithGenerator(gen func(chan<- *importer.ScanResult)) 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