testing

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: LGPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetaWithRelations

func MetaWithRelations(m *charm.Meta, relations ...string) *charm.Meta

MetaWithRelations returns m with Provides and Requires set to the given relations, where each relation is specified as a white-space-separated triple:

role name interface

where role specifies the role of the interface ("provides" or "requires"), name holds the relation name and interface holds the interface relation type.

If m is nil, new(charm.Meta) will be used instead.

func MetaWithResources

func MetaWithResources(m *charm.Meta, resources ...string) *charm.Meta

MetaWithResources returns m with Resources set to a set of resources with the given names. If m is nil, new(charm.Meta) will be used instead.

The path and description of the resources are derived from the resource name by adding a "-file" and a " description" suffix respectively.

func MetaWithSupportedSeries

func MetaWithSupportedSeries(m *charm.Meta, series ...string) *charm.Meta

MetaWithSupportedSeries returns m with Series set to series. If m is nil, new(charm.Meta) will be used instead.

Types

type Charm

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

Charm holds a charm for testing. It does not have a representation on disk by default, but can be written to disk using Archive and its ExpandTo method. It implements the charm.Charm interface.

All methods on Charm may be called concurrently.

func NewCharm

func NewCharm(c *gc.C, spec CharmSpec) *Charm

NewCharm returns a charm following the given specification.

func NewCharmMeta

func NewCharmMeta(meta *charm.Meta) *Charm

NewCharmMeta returns a charm with the given metadata. It doesn't take a *gc.C, so it can be used at init time, for example in table-driven tests.

func (*Charm) Actions

func (ch *Charm) Actions() *charm.Actions

Actions implements charm.Charm.Actions.

func (*Charm) Archive

func (ch *Charm) Archive() *charm.CharmArchive

Archive returns a charm archive holding the charm.

func (*Charm) ArchiveBytes

func (ch *Charm) ArchiveBytes() []byte

ArchiveBytes returns the contents of the charm archive holding the charm.

func (*Charm) ArchiveTo

func (c *Charm) ArchiveTo(w io.Writer) error

ArchiveTo implements ArchiveTo as implemented by *charm.Dir, enabling the charm to be used in some APIs that check for that method.

func (*Charm) Config

func (ch *Charm) Config() *charm.Config

Config implements charm.Charm.Config.

func (*Charm) Meta

func (ch *Charm) Meta() *charm.Meta

Meta implements charm.Charm.Meta.

func (*Charm) Metrics

func (ch *Charm) Metrics() *charm.Metrics

Metrics implements charm.Charm.Metrics.

func (*Charm) Revision

func (ch *Charm) Revision() int

Revision implements charm.Charm.Revision.

func (*Charm) Size

func (c *Charm) Size() int64

Size returns the size of the charm's archive blob.

type CharmSpec

type CharmSpec struct {
	// Meta holds the contents of metadata.yaml.
	Meta string

	// Config holds the contents of config.yaml.
	Config string

	// Actions holds the contents of actions.yaml.
	Actions string

	// Metrics holds the contents of metrics.yaml.
	Metrics string

	// Files holds any additional files that should be
	// added to the charm. If this is nil, a minimal set
	// of files will be added to ensure the charm is readable.
	Files []filetesting.Entry

	// Revision specifies the revision of the charm.
	Revision int
}

CharmSpec holds the specification for a charm. The fields hold data in YAML format.

type IsolatedMgoSuite

type IsolatedMgoSuite struct {
	jujutesting.IsolationSuite
	jujutesting.MgoSuite
}

func (*IsolatedMgoSuite) SetUpSuite

func (s *IsolatedMgoSuite) SetUpSuite(c *gc.C)

func (*IsolatedMgoSuite) SetUpTest

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

func (*IsolatedMgoSuite) TearDownSuite

func (s *IsolatedMgoSuite) TearDownSuite(c *gc.C)

func (*IsolatedMgoSuite) TearDownTest

func (s *IsolatedMgoSuite) TearDownTest(c *gc.C)

type MockStore

type MockStore struct {

	// ArchiveSHA256 holds the hex-encoded SHA256 checksum
	// of the charm archive served by the mock store.
	ArchiveSHA256           string
	Downloads               []*charm.URL
	DownloadsNoStats        []*charm.URL
	Authorizations          []string
	Metadata                []string
	InfoRequestCount        int
	InfoRequestCountNoStats int
	DefaultSeries           string
	// contains filtered or unexported fields
}

MockStore provides a mock charm store implementation useful when testing.

func NewMockStore

func NewMockStore(c *gc.C, repo *Repo, charms map[string]int) *MockStore

NewMockStore creates a mock charm store containing the specified charms.

func (*MockStore) Address

func (s *MockStore) Address() string

Address returns the URL used to make requests to the mock store.

func (*MockStore) Close

func (s *MockStore) Close()

Close closes the mock store's socket.

func (*MockStore) ServeHTTP

func (s *MockStore) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.ServeHTTP

func (*MockStore) UpdateStoreRevision

func (s *MockStore) UpdateStoreRevision(ch string, rev int)

UpdateStoreRevision sets the revision of the specified charm to rev.

type Repo

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

Repo represents a charm repository used for testing.

func NewRepo

func NewRepo(path, defaultSeries string) *Repo

NewRepo returns a new testing charm repository rooted at the given path, relative to the package directory of the calling package, using defaultSeries as the default series.

func (*Repo) BundleArchive

func (r *Repo) BundleArchive(dst, name string) *charm.BundleArchive

BundleArchive returns an actual charm.BundleArchive created from a new bundle archive file created from the bundle directory named name, in the directory dst.

func (*Repo) BundleArchivePath

func (r *Repo) BundleArchivePath(dst, name string) string

BundleArchivePath returns the path to a new bundle archive file in the directory dst, created from the bundle directory named name.

func (*Repo) BundleDir

func (r *Repo) BundleDir(name string) *charm.BundleDir

BundleDir returns the actual charm.BundleDir named name.

func (*Repo) BundleDirPath

func (r *Repo) BundleDirPath(name string) string

BundleDirPath returns the path to a bundle directory with the given name in the default series

func (*Repo) CharmArchive

func (r *Repo) CharmArchive(dst, name string) *charm.CharmArchive

CharmArchive returns an actual charm.CharmArchive created from a new charm archive file created from the charm directory named name, in the directory dst.

func (*Repo) CharmArchivePath

func (r *Repo) CharmArchivePath(dst, name string) string

CharmArchivePath returns the path to a new charm archive file in the directory dst, created from the charm directory named name.

func (*Repo) CharmDir

func (r *Repo) CharmDir(name string) *charm.CharmDir

CharmDir returns the actual charm.CharmDir named name.

func (*Repo) CharmDirPath

func (r *Repo) CharmDirPath(name string) string

CharmDirPath returns the path to a charm directory with the given name in the default series

func (*Repo) ClonedBundleDirPath

func (r *Repo) ClonedBundleDirPath(dst, name string) string

ClonedDirPath returns the path to a new copy of the default bundle directory named name.

func (*Repo) ClonedDir

func (r *Repo) ClonedDir(dst, name string) *charm.CharmDir

ClonedDir returns an actual charm.CharmDir based on a new copy of the charm directory named name, in the directory dst.

func (*Repo) ClonedDirPath

func (r *Repo) ClonedDirPath(dst, name string) string

ClonedDirPath returns the path to a new copy of the default charm directory named name.

func (*Repo) ClonedURL

func (r *Repo) ClonedURL(dst, series, name string) *charm.URL

ClonedURL makes a copy of the charm directory. It will create a directory with the series name if it does not exist, and then clone the charm named name into that directory. The return value is a URL pointing at the local charm.

func (*Repo) Path

func (r *Repo) Path() string

func (*Repo) RenamedClonedDirPath

func (r *Repo) RenamedClonedDirPath(dst, name, newName string) string

RenamedClonedDirPath returns the path to a new copy of the default charm directory named name, renamed to newName.

Jump to

Keyboard shortcuts

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