testing

package
Version: v0.0.0-...-ab85226 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2015 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 new charm

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) 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.

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 MockCharmStore

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

MockCharmStore implements charm/charmrepo.Interface and is used to isolate tests that would otherwise need to hit the real charm store.

func NewMockCharmStore

func NewMockCharmStore() *MockCharmStore

func (*MockCharmStore) AuthAttrs

func (s *MockCharmStore) AuthAttrs() string

AuthAttrs returns the AuthAttrs for this charm store.

func (*MockCharmStore) DefaultSeries

func (s *MockCharmStore) DefaultSeries() string

DefaultSeries returns the default series for this charm store.

func (*MockCharmStore) Get

func (s *MockCharmStore) Get(charmURL *charm.URL) (charm.Charm, error)

Get implements charm/charmrepo.Interface.Get.

func (*MockCharmStore) Latest

func (s *MockCharmStore) Latest(charmURLs ...*charm.URL) ([]charmrepo.CharmRevision, error)

Latest implements charm/charmrepo.Interface.Latest.

func (*MockCharmStore) Resolve

func (s *MockCharmStore) Resolve(ref *charm.Reference) (*charm.URL, error)

Resolve implements charm/charmrepo.Interface.Resolve.

func (*MockCharmStore) SetAuthAttrs

func (s *MockCharmStore) SetAuthAttrs(auth string)

SetAuthAttrs overwrites the value returned by AuthAttrs

func (*MockCharmStore) SetCharm

func (s *MockCharmStore) SetCharm(charmURL *charm.URL, archive *charm.CharmArchive) error

SetCharm adds and removes charms in s. The affected charm is identified by charmURL, which must be revisioned. If archive is nil, the charm will be removed; otherwise, it will be stored. It is an error to store a archive under a charmURL that does not share its name and revision.

func (*MockCharmStore) SetDefaultSeries

func (s *MockCharmStore) SetDefaultSeries(series string)

SetDefaultSeries overwrites the default series for this charm store.

func (*MockCharmStore) TestMode

func (s *MockCharmStore) TestMode() bool

TestMode returns the test mode setting of this charm store.

func (*MockCharmStore) WithTestMode

func (s *MockCharmStore) WithTestMode(testMode bool) charmrepo.Interface

WithTestMode returns a repository Interface where testMode is set to value passed to this method.

type MockStore

type MockStore struct {
	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) 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
t or T : Toggle theme light dark auto
y or Y : Canonical URL