mock

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mock contains helper functions for generating mock objects for testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deployment

func Deployment() D.Deployment

Deployment returns a mock implementation of deploy.Deployment Deployment has 4 apps: foo, bar, baz, quux Each app runs in 1 account:

foo, bar, baz run in prod
quux runs in test

Each app has one cluster: foo-prod, bar-prod, baz-prod Each cluster runs in one region: us-east-1 Each cluster contains 1 AZ with two instances

func Deps

func Deps() deps.Deps

Deps returns a deps.Deps object that contains mocks. The mocks implement their interfaces by performing no-ops.

func NewDeployment

func NewDeployment(apps map[string]D.AppMap) D.Deployment

NewDeployment returns a mock implementation of deploy.Deployment Pass in a deploy.AppMap, for example:

 map[string]deploy.AppMap{
		"foo":  deploy.AppMap{"prod": {"foo-prod": {"us-east-1": {"foo-prod-v001": []string{"i-d3e3d611", "i-63f52e25"}}}}},
		"bar":  deploy.AppMap{"prod": {"bar-prod": {"us-east-1": {"bar-prod-v011": []string{"i-d7f06d45", "i-ce433cf1"}}}}},
		"baz":  deploy.AppMap{"prod": {"baz-prod": {"us-east-1": {"baz-prod-v004": []string{"i-25b86646", "i-573d46d5"}}}}},
		"quux": deploy.AppMap{"test": {"quux-test": {"us-east-1": {"quux-test-v004": []string{"i-25b866ab", "i-892d46d5"}}}}},
	}

Types

type AppFactory

type AppFactory struct {
}

AppFactory creates App objects used for testing

func (AppFactory) App

func (factory AppFactory) App() *D.App

App creates a mock App

type Checker

type Checker struct {
	Error error
}

Checker implements deps.Checker

func (Checker) Check

func (c Checker) Check(term chaosmonkey.Termination, appCfg chaosmonkey.AppConfig, endHour int, loc *time.Location) error

Check implements deps.Checker.Check

type Clock

type Clock struct {
	Time time.Time
}

Clock implements clock.Clock

func (Clock) Now

func (c Clock) Now() time.Time

Now implements clock.Clock.Now

type ConfigGetter

type ConfigGetter struct{}

ConfigGetter implements chaosmonkey.Getter

func (ConfigGetter) Get

Get implements chaosmonkey.Getter.Get

type Env

type Env struct {
	IsInTest bool
}

Env implements chaosmonkey.Env

func (Env) InTest

func (e Env) InTest() bool

InTest implements chaosmonkey.Env.InTest

type ErrorCounter

type ErrorCounter struct{}

ErrorCounter implements chaosmonkey.Publisher

func (ErrorCounter) Increment

func (e ErrorCounter) Increment() error

Increment implements chaosmonkey.ErrorCounter.Increment

type Instance

type Instance struct {
	App, Account, Stack, Cluster, Region, ASG, InstanceID string
}

Instance implements instance.Instance

func (Instance) ASGName

func (i Instance) ASGName() string

ASGName implements instance.ASGName

func (Instance) AccountName

func (i Instance) AccountName() string

AccountName implements instance.AccountName

func (Instance) AppName

func (i Instance) AppName() string

AppName implements instance.AppName

func (Instance) CloudProvider

func (i Instance) CloudProvider() string

CloudProvider implements instance.IsContainer

func (Instance) ClusterName

func (i Instance) ClusterName() string

ClusterName implements instance.ClusterName

func (Instance) ID

func (i Instance) ID() string

ID implements instance.ID

func (Instance) RegionName

func (i Instance) RegionName() string

RegionName implements instance.RegionName

func (Instance) StackName

func (i Instance) StackName() string

StackName implements instance.StackName

type Outage

type Outage struct{}

Outage is a mock implementation of outage.Outage

func (Outage) Outage

func (o Outage) Outage() (bool, error)

Outage implemnets outage.Outage.Outage

type Terminator

type Terminator struct {
	Instance chaosmonkey.Instance
	Ncalls   int
	Error    error
}

Terminator implements term.terminator

func (*Terminator) Execute

func (t *Terminator) Execute(trm chaosmonkey.Termination) error

Execute pretends to terminate an instance

type Tracker

type Tracker struct {
	Error error
}

Tracker implements chaosmonkey.Tracker

func (Tracker) Track

func (t Tracker) Track(trm chaosmonkey.Termination) error

Track implements chaosmonkey.Tracker.Track

Jump to

Keyboard shortcuts

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