Documentation ¶
Index ¶
- func FinishMetadata(meta *backups.Metadata)
- func NewArchive(meta *backups.Metadata, files, dump []File) (*bytes.Buffer, error)
- func NewArchiveBasic(meta *backups.Metadata) (*bytes.Buffer, error)
- func NewMetadata() *backups.Metadata
- func NewMetadataStarted() *backups.Metadata
- func SHA1SumFile(c *gc.C, file *os.File) string
- func SetOrigin(meta *backups.Metadata, envUUID, machine, hostname string)
- func UpdateNotes(meta *backups.Metadata, notes string) *backups.Metadata
- type BaseSuite
- type FakeBackups
- func (b *FakeBackups) Add(archive io.Reader, meta *backups.Metadata) (string, error)
- func (b *FakeBackups) Create(meta *backups.Metadata, paths *backups.Paths, dbInfo *backups.DBInfo) error
- func (b *FakeBackups) Get(id string) (*backups.Metadata, io.ReadCloser, error)
- func (b *FakeBackups) List() ([]*backups.Metadata, error)
- func (b *FakeBackups) Remove(id string) error
- func (b *FakeBackups) Restore(bkpId string, args backups.RestoreArgs) error
- type FakeStorage
- func (s *FakeStorage) Add(meta filestorage.Metadata, file io.Reader) (string, error)
- func (s *FakeStorage) CheckCalled(c *gc.C, id string, meta filestorage.Metadata, file io.Reader, calls ...string)
- func (s *FakeStorage) Close() error
- func (s *FakeStorage) Get(id string) (filestorage.Metadata, io.ReadCloser, error)
- func (s *FakeStorage) List() ([]filestorage.Metadata, error)
- func (s *FakeStorage) Metadata(id string) (filestorage.Metadata, error)
- func (s *FakeStorage) Remove(id string) error
- func (s *FakeStorage) SetFile(id string, file io.Reader) error
- type File
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FinishMetadata ¶
FinishMetadata finishes a metadata with test values.
func NewArchive ¶
NewArchive returns a new archive file containing the files.
func NewArchiveBasic ¶
NewArchiveBasic returns a new archive file with a few files provided.
func NewMetadata ¶
NewMetadata returns a Metadata to use for testing.
func NewMetadataStarted ¶
NewMetadataStarted returns a Metadata to use for testing.
func SHA1SumFile ¶
SHA1SumFile returns the RFC 3230 SHA hash of the file.
Types ¶
type BaseSuite ¶
type BaseSuite struct { testing.IsolationSuite // Meta is a Metadata with standard test values. Meta *backups.Metadata // Storage is a FileStorage to use when testing backups. Storage *FakeStorage }
The base suite for backups testing.
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 // 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.
func (*FakeBackups) Create ¶
func (b *FakeBackups) Create(meta *backups.Metadata, paths *backups.Paths, dbInfo *backups.DBInfo) error
Create creates and stores a new juju backup archive and returns its associated metadata.
func (*FakeBackups) Get ¶
func (b *FakeBackups) Get(id string) (*backups.Metadata, io.ReadCloser, error)
Get returns the metadata and archive file associated with the ID.
func (*FakeBackups) List ¶
func (b *FakeBackups) List() ([]*backups.Metadata, error)
List returns the metadata for all stored backups.
func (*FakeBackups) Remove ¶
func (b *FakeBackups) Remove(id string) error
Remove deletes the backup from storage.
func (*FakeBackups) Restore ¶
func (b *FakeBackups) Restore(bkpId string, args backups.RestoreArgs) error
Restore restores a machine to a backed up status.
type FakeStorage ¶
type FakeStorage struct { // Calls contains the order in which methods were called. Calls []string // ID is the stored backup ID to return. ID string // Meta holds the Metadata to return. Meta filestorage.Metadata // MetaList holds the Metadata list to return. MetaList []filestorage.Metadata // File holds the stored file to return. File io.ReadCloser // Error holds the error to return. Error error // IDArg holds the ID that was passed in. IDArg string // MetaArg holds the Metadata that was passed in. MetaArg filestorage.Metadata // FileArg holds the file that was passed in. FileArg io.Reader }
FakeStorage is a FileStorage implementation to use when testing backups.
func (*FakeStorage) Add ¶
func (s *FakeStorage) Add(meta filestorage.Metadata, file io.Reader) (string, error)
func (*FakeStorage) CheckCalled ¶
func (s *FakeStorage) CheckCalled(c *gc.C, id string, meta filestorage.Metadata, file io.Reader, calls ...string)
CheckCalled verifies that the fake was called as expected.
func (*FakeStorage) Close ¶
func (s *FakeStorage) Close() error
func (*FakeStorage) Get ¶
func (s *FakeStorage) Get(id string) (filestorage.Metadata, io.ReadCloser, error)
func (*FakeStorage) List ¶
func (s *FakeStorage) List() ([]filestorage.Metadata, error)
func (*FakeStorage) Metadata ¶
func (s *FakeStorage) Metadata(id string) (filestorage.Metadata, error)
func (*FakeStorage) Remove ¶
func (s *FakeStorage) Remove(id string) error
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.