testing

package
v0.0.0-...-5facc9d Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2013 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package testing provide test helpers for various actions.

Index

Constants

This section is empty.

Variables

View Source
var IsRecorded gocheck.Checker = isRecordedChecker{}

Functions

func CleanQ

func CleanQ(names ...string)

CleanQ deletes all messages from queues identified by the given names.

Types

type Action

type Action struct {
	User   string
	Action string
	Extra  []interface{}
}

type Cmd

type Cmd struct {
	Cmd  string
	Args []string
	App  provision.App
}

type CommandableProvisioner

type CommandableProvisioner struct {
	FakeProvisioner
	// contains filtered or unexported fields
}

func (*CommandableProvisioner) Commands

func (p *CommandableProvisioner) Commands() []cmd.Command

type FakeApp

type FakeApp struct {
	Commands []string
	// contains filtered or unexported fields
}

Fake implementation for provision.App.

func NewFakeApp

func NewFakeApp(name, platform string, units int) *FakeApp

func (*FakeApp) AddUnit

func (a *FakeApp) AddUnit(u *FakeUnit)

func (*FakeApp) GetCommands

func (a *FakeApp) GetCommands() []string

func (*FakeApp) GetDeploys

func (a *FakeApp) GetDeploys() uint

func (*FakeApp) GetName

func (a *FakeApp) GetName() string

func (*FakeApp) GetPlatform

func (a *FakeApp) GetPlatform() string

func (*FakeApp) HasLog

func (a *FakeApp) HasLog(source, message string) bool

func (*FakeApp) IsReady

func (a *FakeApp) IsReady() bool

func (*FakeApp) Log

func (a *FakeApp) Log(message, source string) error

func (*FakeApp) Logs

func (a *FakeApp) Logs() []string

func (*FakeApp) ProvisionedUnits

func (a *FakeApp) ProvisionedUnits() []provision.AppUnit

func (*FakeApp) Ready

func (a *FakeApp) Ready() error

func (*FakeApp) RemoveUnit

func (a *FakeApp) RemoveUnit(id string) error

func (*FakeApp) Restart

func (a *FakeApp) Restart(w io.Writer) error

func (*FakeApp) Run

func (a *FakeApp) Run(cmd string, w io.Writer, once bool) error

func (*FakeApp) SerializeEnvVars

func (a *FakeApp) SerializeEnvVars() error

func (*FakeApp) SetUnitStatus

func (a *FakeApp) SetUnitStatus(s provision.Status, index int)

type FakeCommand

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

func (*FakeCommand) Calls

func (c *FakeCommand) Calls() int32

func (*FakeCommand) Info

func (c *FakeCommand) Info() *cmd.Info

func (*FakeCommand) Run

func (c *FakeCommand) Run(*cmd.Context, *cmd.Client) error

type FakeProvisioner

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

Fake implementation for provision.Provisioner.

func NewFakeProvisioner

func NewFakeProvisioner() *FakeProvisioner

func (*FakeProvisioner) AddUnits

func (p *FakeProvisioner) AddUnits(app provision.App, n uint) ([]provision.Unit, error)

func (*FakeProvisioner) Addr

func (p *FakeProvisioner) Addr(app provision.App) (string, error)

func (*FakeProvisioner) CollectStatus

func (p *FakeProvisioner) CollectStatus() ([]provision.Unit, error)

func (*FakeProvisioner) Deploy

func (p *FakeProvisioner) Deploy(app provision.App, version string, w io.Writer) error

func (*FakeProvisioner) Destroy

func (p *FakeProvisioner) Destroy(app provision.App) error

func (*FakeProvisioner) ExecuteCommand

func (p *FakeProvisioner) ExecuteCommand(stdout, stderr io.Writer, app provision.App, cmd string, args ...string) error

ExecuteCommand will pretend to execute the given command, recording data about it.

The output of the command must be prepared with PrepareOutput, and failures must be prepared with PrepareFailure. In case of failure, the prepared output will be sent to the standard error stream, otherwise, it will be sent to the standard error stream.

When there is no output nor failure prepared, ExecuteCommand will return a timeout error.

func (*FakeProvisioner) ExecuteCommandOnce

func (p *FakeProvisioner) ExecuteCommandOnce(stdout, stderr io.Writer, app provision.App, cmd string, args ...string) error

func (*FakeProvisioner) GetCmds

func (p *FakeProvisioner) GetCmds(cmd string, app provision.App) []Cmd

Returns the number of calls to restart. GetCmds returns a list of commands executed in an app. If you don't specify the command (an empty string), it will return all commands executed in the given app.

func (*FakeProvisioner) GetUnits

func (p *FakeProvisioner) GetUnits(app provision.App) []provision.Unit

func (*FakeProvisioner) HasCName

func (p *FakeProvisioner) HasCName(app provision.App, cname string) bool

func (*FakeProvisioner) InstallDeps

func (p *FakeProvisioner) InstallDeps(app provision.App, w io.Writer) error

func (*FakeProvisioner) InstalledDeps

func (p *FakeProvisioner) InstalledDeps(app provision.App) int

InstalledDeps returns the number of InstallDeps calls for the given app.

func (*FakeProvisioner) PrepareFailure

func (p *FakeProvisioner) PrepareFailure(method string, err error)

PrepareFailure prepares a failure for the given method name.

For instance, PrepareFailure("Deploy", errors.New("Deploy failed")) will cause next Deploy call to return the given error. Multiple calls to this method will enqueue failures, i.e. three calls to PrepareFailure("Deploy"...) means that the three next Deploy call will fail.

func (*FakeProvisioner) PrepareOutput

func (p *FakeProvisioner) PrepareOutput(b []byte)

PrepareOutput sends the given slice of bytes to a queue of outputs.

Each prepared output will be used in the ExecuteCommand. It might be sent to the standard output or standard error. See ExecuteCommand docs for more details.

func (*FakeProvisioner) Provision

func (p *FakeProvisioner) Provision(app provision.App) error

func (*FakeProvisioner) Provisioned

func (p *FakeProvisioner) Provisioned(app provision.App) bool

Provisioned checks whether the given app has been provisioned.

func (*FakeProvisioner) RemoveUnit

func (p *FakeProvisioner) RemoveUnit(app provision.App, name string) error

func (*FakeProvisioner) Reset

func (p *FakeProvisioner) Reset()

Reset cleans up the FakeProvisioner, deleting all apps and their data. It also deletes prepared failures and output. It's like calling NewFakeProvisioner again, without all the allocations.

func (*FakeProvisioner) Restart

func (p *FakeProvisioner) Restart(app provision.App) error

func (*FakeProvisioner) Restarts

func (p *FakeProvisioner) Restarts(app provision.App) int

Restarts returns the number of restarts for a given app.

func (*FakeProvisioner) SetCName

func (p *FakeProvisioner) SetCName(app provision.App, cname string) error

func (FakeProvisioner) Swap

func (FakeProvisioner) Swap(app1, app2 provision.App) error

func (*FakeProvisioner) UnsetCName

func (p *FakeProvisioner) UnsetCName(app provision.App, cname string) error

func (*FakeProvisioner) Version

func (p *FakeProvisioner) Version(app provision.App) string

Version returns the last deployed for a given app.

type FakeQ

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

func (*FakeQ) Delete

func (q *FakeQ) Delete(m *queue.Message) error

func (*FakeQ) Get

func (q *FakeQ) Get(timeout time.Duration) (*queue.Message, error)

func (*FakeQ) Put

func (q *FakeQ) Put(m *queue.Message, delay time.Duration) error

func (*FakeQ) Release

func (q *FakeQ) Release(m *queue.Message, delay time.Duration) error

type FakeQFactory

type FakeQFactory struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFakeQFactory

func NewFakeQFactory() *FakeQFactory

func (*FakeQFactory) Get

func (f *FakeQFactory) Get(name string) (queue.Q, error)

func (*FakeQFactory) Handler

func (f *FakeQFactory) Handler(fn func(*queue.Message), names ...string) (queue.Handler, error)

type FakeUnit

type FakeUnit struct {
	Name       string
	Ip         string
	InstanceId string
	Machine    int
	Status     provision.Status
}

Fake implementation for provision.Unit.

func (*FakeUnit) GetInstanceId

func (u *FakeUnit) GetInstanceId() string

func (*FakeUnit) GetIp

func (u *FakeUnit) GetIp() string

func (*FakeUnit) GetMachine

func (u *FakeUnit) GetMachine() int

func (*FakeUnit) GetName

func (u *FakeUnit) GetName() string

func (*FakeUnit) GetStatus

func (u *FakeUnit) GetStatus() provision.Status

type Mail

type Mail struct {
	From string
	To   []string
	Data []byte
}

Mail represents an email message that has been sent to the fake server.

type SMTPServer

type SMTPServer struct {
	// MailBox is the slice that stores all messages that has arrived to
	// the server while it's listening. Use the mutex to access it, or bad
	// things can happen.
	MailBox []Mail
	sync.RWMutex
	// contains filtered or unexported fields
}

SMTPServer is a fake SMTP server implementation.

This SMTP server does not support authentication and is supposed to be used in tests only.

Use NewSMTPServer create a new instance and start serving; SMTPServer.Addr() will get you the address of the server and Stop will stop the server, closing the listener. Every message that arrive at the server is stored in the MailBox slice.

func NewSMTPServer

func NewSMTPServer() (*SMTPServer, error)

NewSMTPServer creates a new SMTP server, for testing purposes.

func (*SMTPServer) Addr

func (s *SMTPServer) Addr() string

Addr returns the address of the server, in the form <host>:<port>.

func (*SMTPServer) Reset

func (s *SMTPServer) Reset()

Reset resets the server, cleaning up the mailbox.

func (*SMTPServer) Stop

func (s *SMTPServer) Stop()

Stop stops the server. It's safe to call this method multiple times.

type T

type T struct {
	Admin        user
	AdminTeam    team
	S3Server     *s3test.Server
	IamServer    *iamtest.Server
	GitAPIServer string
	GitRWHost    string
	GitROHost    string
}

func (*T) RollbackGitConfs

func (t *T) RollbackGitConfs(c *gocheck.C)

func (*T) SetGitConfs

func (t *T) SetGitConfs(c *gocheck.C)

func (*T) StartAmzS3AndIAM

func (t *T) StartAmzS3AndIAM(c *gocheck.C)

func (*T) StartGandalfTestServer

func (t *T) StartGandalfTestServer(h http.Handler) *httptest.Server

starts a new httptest.Server and returns it Also changes git:host, git:port and git:protocol to match the server's url

Jump to

Keyboard shortcuts

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