storetesting

package
v5.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Charms = testing.NewRepo("charm-repo", "quantal")

Charms holds the testing charm repository.

Functions

func AssertBaseEntity

func AssertBaseEntity(c *gc.C, db *mgo.Collection, expect *mongodoc.BaseEntity)

AssertBaseEntity checks that db contains a base entity that matches expect.

func AssertEntity

func AssertEntity(c *gc.C, db *mgo.Collection, expect *mongodoc.Entity)

AssertEntity checks that db contains an entity that matches expect.

func JSONReader

func JSONReader(v interface{}) io.Reader

JSONReader creates an io.Reader which can read the Marshalled value of v.

func MetaWithCategories

func MetaWithCategories(m *charm.Meta, categories ...string) *charm.Meta

MetaWithCategories returns m with Categories set to categories. If m is nil, new(charm.Meta) will be used instead.

func MetaWithDockerResources added in v5.1.1

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

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

The description of the resources are derived from the resource name by adding " description" suffix respectively.

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.

func MetaWithTags

func MetaWithTags(m *charm.Meta, tags ...string) *charm.Meta

MetaWithTags returns m with Tags set to tags. If m is nil, new(charm.Meta) will be used instead.

func MongoJSEnabled

func MongoJSEnabled() bool

MongoJSEnabled reports whether testing code should run tests that rely on JavaScript inside MongoDB.

func MustMarshalJSON

func MustMarshalJSON(v interface{}) []byte

MustMarshalJSON marshals the specified value using json.Marshal and returns the corresponding byte slice. If there is an error marshalling the value then MustMarshalJSON will panic.

func NormalizeBaseEntity

func NormalizeBaseEntity(be *mongodoc.BaseEntity) *mongodoc.BaseEntity

NormalizeBaseEntity modifies a base entity so that it can be compared with another normalized base entity using jc.DeepEquals.

func RelationMeta

func RelationMeta(relations ...string) *charm.Meta

RelationMeta returns charm metadata for a charm with 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.

Types

type BaseEntityBuilder

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

BaseEntityBuilder provides a convenient way to describe a mongodoc.BaseEntity for tests that is correctly formed and contains the desired information.

func NewBaseEntity

func NewBaseEntity(url string) BaseEntityBuilder

NewBaseEntity creates a new BaseEntityBuilder for the provided URL.

func (BaseEntityBuilder) Build

Build creates a mongodoc.BaseEntity from the BaseEntityBuilder.

func (BaseEntityBuilder) WithACLs

func (b BaseEntityBuilder) WithACLs(channel params.Channel, acls mongodoc.ACL) BaseEntityBuilder

WithACLs sets the ACLs field on the BaseEntity.

func (BaseEntityBuilder) WithPromulgated

func (b BaseEntityBuilder) WithPromulgated(promulgated bool) BaseEntityBuilder

WithPromulgated sets the promulgated flag on the BaseEntity.

type Blob

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

Blob represents a blob of data - a zip archive. Since it implements charmstore.ArchiverTo, it can be used to add charms or bundles with specific contents to the charm store.

func NewBlob

func NewBlob(files []File) *Blob

NewBlob returns a blob that holds the given files.

func (*Blob) ArchiveTo

func (b *Blob) ArchiveTo(w io.Writer) error

ArchiveTo implements charmstore.ArchiverTo.ArchiveTo.

func (*Blob) Bytes

func (b *Blob) Bytes() []byte

Bytes returns the contents of the blob.

func (*Blob) Size

func (b *Blob) Size() int64

Size returns the size of the blob.

type Bundle

type Bundle struct {
	*Blob
	// contains filtered or unexported fields
}

Bundle implements an in-memory charm.Bundle that can be archived.

Note that because it implements charmstore.ArchiverTo, it can be used as an argument to charmstore.Store.AddBundleWithArchive.

func NewBundle

func NewBundle(data *charm.BundleData) *Bundle

NewBundle returns a bundle implementation that contains the given bundle data.

func (*Bundle) Data

func (b *Bundle) Data() *charm.BundleData

Data implements charm.Bundle.Data.

func (*Bundle) ReadMe

func (b *Bundle) ReadMe() string

ReadMe implements charm.Bundle.ReadMe.

type Charm

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

Charm implements an in-memory charm.Charm that can be archived.

Note that because it implements charmstore.ArchiverTo, it can be used as an argument to charmstore.Store.AddCharmWithArchive.

func NewCharm

func NewCharm(meta *charm.Meta) *Charm

NewCharm returns a charm implementation that contains the given charm metadata. All charm.Charm methods other than Meta will return empty values. If meta is nil, new(charm.Meta) will be used.

func (*Charm) Actions

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

Actions implements charm.Charm.Actions.

func (*Charm) ArchiveTo

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

ArchiveTo implements charmstore.ArchiverTo.

func (*Charm) Bytes

func (c *Charm) Bytes() []byte

Bytes returns the contents of the charm's archive.

func (*Charm) Config

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

Config implements charm.Charm.Config.

func (*Charm) Meta

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

Meta implements charm.Charm.Meta.

func (*Charm) Metrics

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

Metrics implements charm.Charm.Metrics.

func (*Charm) Revision

func (c *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.

func (*Charm) WithMetrics

func (c *Charm) WithMetrics(metrics *charm.Metrics) *Charm

type ElasticSearchSuite

type ElasticSearchSuite struct {
	ES *elasticsearch.Database

	TestIndex string
	// contains filtered or unexported fields
}

ElasticSearchSuite defines a test suite that connects to an elastic-search server. The address of the server depends on the value of the JUJU_TEST_ELASTICSEARCH environment variable, which can be "none" (do not start or connect to a server) or host:port holding the address and port of the server to connect to. If JUJU_TEST_ELASTICSEARCH is not specified then localhost:9200 will be used.

func (*ElasticSearchSuite) LoadESConfig

func (s *ElasticSearchSuite) LoadESConfig(index string, settings, mapping interface{}) error

LoadESConfig loads a canned test configuration to the specified index

func (*ElasticSearchSuite) NewIndex

func (s *ElasticSearchSuite) NewIndex(c *gc.C) string

NewIndex creates a new index name and ensures that it will be cleaned up at end of the test.

func (*ElasticSearchSuite) SetUpSuite

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

func (*ElasticSearchSuite) SetUpTest

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

func (*ElasticSearchSuite) TearDownSuite

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

func (*ElasticSearchSuite) TearDownTest

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

type EntityBuilder

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

EntityBuilder provides a convenient way to describe a mongodoc.Entity for tests that is correctly formed and contains the desired information.

func NewEntity

func NewEntity(url string) EntityBuilder

NewEntity creates a new EntityBuilder for the provided URL.

func (EntityBuilder) Build

func (b EntityBuilder) Build() *mongodoc.Entity

Build creates a mongodoc.Entity from the EntityBuilder.

func (EntityBuilder) WithPromulgatedURL

func (b EntityBuilder) WithPromulgatedURL(url string) EntityBuilder

WithPromulgatedURL sets the PromulgatedURL and PromulgatedRevision of the entity being built.

type File

type File struct {
	Name string
	Data []byte
}

File represents a file which will be added to a new blob.

type IsolatedMgoESSuite

type IsolatedMgoESSuite struct {
	jujutesting.IsolatedMgoSuite
	ElasticSearchSuite
}

func (*IsolatedMgoESSuite) SetUpSuite

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

func (*IsolatedMgoESSuite) SetUpTest

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

func (*IsolatedMgoESSuite) TearDownSuite

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

func (*IsolatedMgoESSuite) TearDownTest

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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