testing

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FinishMetadata

func FinishMetadata(meta *backups.Metadata)

FinishMetadata finishes a metadata with test values.

func NewArchive

func NewArchive(meta *backups.Metadata, files, dump []File) (*bytes.Buffer, error)

NewArchive returns a new archive file containing the files.

func NewArchiveBasic

func NewArchiveBasic(meta *backups.Metadata) (*bytes.Buffer, error)

NewArchiveBasic returns a new archive file with a few files provided.

func NewArchiveV0

func NewArchiveV0(meta *backups.Metadata, files, dump []File) (*bytes.Buffer, error)

NewArchiveV0 returns a new archive file containing the files, in v0 format.

func NewMetadata

func NewMetadata() *backups.Metadata

NewMetadata returns a Metadata to use for testing.

func NewMetadataStarted

func NewMetadataStarted() *backups.Metadata

NewMetadataStarted returns a Metadata to use for testing.

func SHA1SumFile

func SHA1SumFile(c *gc.C, file *os.File) string

SHA1SumFile returns the RFC 3230 SHA hash of the file.

func SetOrigin

func SetOrigin(meta *backups.Metadata, modelUUID, machine, hostname string)

SetOrigin updates the metadata's origin with the privided information.

func UpdateNotes

func UpdateNotes(meta *backups.Metadata, notes string) *backups.Metadata

UpdateNotes derives a new Metadata with new notes.

Types

type BaseSuite

type BaseSuite struct {
	testing.IsolationSuite
	// Meta is a Metadata with standard test values.
	Meta *backups.Metadata
}

BaseSuite is the base suite for backups testing.

func (*BaseSuite) SetUpTest

func (s *BaseSuite) SetUpTest(c *gc.C)

type FakeBackups

type FakeBackups struct {
	// Calls contains the order in which methods were called.
	Calls []string

	// Meta holds the Metadata to return.
	Meta *backups.Metadata
	// MetaList holds the Metadata list to return.
	MetaList []*backups.Metadata
	// Archive holds the archive file to return.
	Archive io.ReadCloser
	// Error holds the error to return.
	Error error
	// Filename holds the name of the file to return.
	Filename string

	// IDArg holds the ID that was passed in.
	IDArg string
	// PathsArg holds the Paths that was passed in.
	PathsArg *backups.Paths
	// DBInfoArg holds the ConnInfo that was passed in.
	DBInfoArg *backups.DBInfo
	// MetaArg holds the backup metadata that was passed in.
	MetaArg *backups.Metadata
	// PrivateAddr Holds the address for the internal network of the machine.
	PrivateAddr string
	// InstanceId is the id of the machine to be restored.
	InstanceId instance.Id
	// ArchiveArg holds the backup archive that was passed in.
	ArchiveArg io.Reader
}

FakeBackups is an implementation of Backups to use for testing. TODO: (hml) 2018-04-25 Let's change FakeBackups to using gomock or base.APICaller. Checking calls made and arguments is a pain.

func (*FakeBackups) Create

func (b *FakeBackups) Create(
	meta *backups.Metadata,
	paths *backups.Paths,
	dbInfo *backups.DBInfo,
) (string, error)

Create creates and stores a new juju backup archive and returns its associated metadata.

func (*FakeBackups) Get

Get returns the metadata and archive file associated with the ID.

type File

type File struct {
	// Name is the path to which the file will be identified in the archive.
	Name string
	// Content is the data that will be written to the archive for the file.
	Content string
	// IsDir determines if the file is a regular file or a directory.
	IsDir bool
}

File represents a file during testing.

func (*File) AddToArchive

func (f *File) AddToArchive(archive *tar.Writer) error

AddToArchive adds the file to the tar archive.

Jump to

Keyboard shortcuts

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