Documentation ¶
Overview ¶
Package testing provide test helpers for various actions.
Index ¶
- Variables
- func CleanQ(names ...string)
- func StartGandalfTestServer(h http.Handler) *httptest.Server
- type Action
- type Cmd
- type CommandableProvisioner
- type FakeApp
- func (a *FakeApp) AddUnit(u *FakeUnit)
- func (a *FakeApp) Envs() map[string]bind.EnvVar
- func (a *FakeApp) GetCommands() []string
- func (a *FakeApp) GetDeploys() uint
- func (a *FakeApp) GetIp() string
- func (a *FakeApp) GetMemory() int
- func (a *FakeApp) GetName() string
- func (a *FakeApp) GetPlatform() string
- func (a *FakeApp) GetSwap() int
- func (a *FakeApp) GetUnits() []bind.Unit
- func (a *FakeApp) HasLog(source, message string) bool
- func (a *FakeApp) InstanceEnv(env string) map[string]bind.EnvVar
- func (a *FakeApp) IsReady() bool
- func (a *FakeApp) Log(message, source string) error
- func (a *FakeApp) Logs() []string
- func (a *FakeApp) ProvisionedUnits() []provision.AppUnit
- func (a *FakeApp) Ready() error
- func (a *FakeApp) RemoveUnit(id string) error
- func (a *FakeApp) Restart(w io.Writer) error
- func (a *FakeApp) Run(cmd string, w io.Writer, once bool) error
- func (a *FakeApp) SerializeEnvVars() error
- func (a *FakeApp) SetEnv(env bind.EnvVar)
- func (a *FakeApp) SetEnvs(envs []bind.EnvVar, publicOnly bool) error
- func (a *FakeApp) SetUnitStatus(s provision.Status, index int)
- func (a *FakeApp) UnsetEnvs(envs []string, publicOnly bool) error
- type FakeCommand
- type FakeProvisioner
- func (p *FakeProvisioner) AddUnits(app provision.App, n uint) ([]provision.Unit, error)
- func (p *FakeProvisioner) Addr(app provision.App) (string, error)
- func (p *FakeProvisioner) CollectStatus() ([]provision.Unit, error)
- func (p *FakeProvisioner) Deploy(app provision.App, version string, w io.Writer) error
- func (p *FakeProvisioner) DeployPipeline() *action.Pipeline
- func (p *FakeProvisioner) Destroy(app provision.App) error
- func (p *FakeProvisioner) ExecuteCommand(stdout, stderr io.Writer, app provision.App, cmd string, args ...string) error
- func (p *FakeProvisioner) ExecuteCommandOnce(stdout, stderr io.Writer, app provision.App, cmd string, args ...string) error
- func (p *FakeProvisioner) ExecutedPipeline() bool
- func (p *FakeProvisioner) GetCmds(cmd string, app provision.App) []Cmd
- func (p *FakeProvisioner) GetUnits(app provision.App) []provision.Unit
- func (p *FakeProvisioner) HasCName(app provision.App, cname string) bool
- func (p *FakeProvisioner) InstallDeps(app provision.App, w io.Writer) error
- func (p *FakeProvisioner) InstalledDeps(app provision.App) int
- func (p *FakeProvisioner) PrepareFailure(method string, err error)
- func (p *FakeProvisioner) PrepareOutput(b []byte)
- func (p *FakeProvisioner) Provision(app provision.App) error
- func (p *FakeProvisioner) Provisioned(app provision.App) bool
- func (p *FakeProvisioner) RemoveUnit(app provision.App, name string) error
- func (p *FakeProvisioner) Reset()
- func (p *FakeProvisioner) Restart(app provision.App) error
- func (p *FakeProvisioner) Restarts(app provision.App) int
- func (p *FakeProvisioner) SetCName(app provision.App, cname string) error
- func (p *FakeProvisioner) Start(app provision.App) error
- func (p *FakeProvisioner) Starts(app provision.App) int
- func (p *FakeProvisioner) Stop(app provision.App) error
- func (*FakeProvisioner) Swap(app1, app2 provision.App) error
- func (p *FakeProvisioner) UnsetCName(app provision.App, cname string) error
- func (p *FakeProvisioner) Version(app provision.App) string
- type FakeQ
- type FakeQFactory
- type FakeUnit
- type Mail
- type SMTPServer
- type T
- type TestHandler
Constants ¶
This section is empty.
Variables ¶
var IsRecorded gocheck.Checker = isRecordedChecker{}
Functions ¶
Types ¶
type CommandableProvisioner ¶
type CommandableProvisioner struct { FakeProvisioner // contains filtered or unexported fields }
func (*CommandableProvisioner) Commands ¶
func (p *CommandableProvisioner) Commands() []cmd.Command
type FakeApp ¶
Fake implementation for provision.App.
func NewFakeApp ¶
func (*FakeApp) GetCommands ¶
func (*FakeApp) GetDeploys ¶
func (*FakeApp) GetPlatform ¶
func (*FakeApp) ProvisionedUnits ¶
func (*FakeApp) RemoveUnit ¶
func (*FakeApp) SerializeEnvVars ¶
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
type FakeProvisioner ¶
type FakeProvisioner struct { CustomPipeline bool // contains filtered or unexported fields }
Fake implementation for provision.Provisioner.
func NewFakeProvisioner ¶
func NewFakeProvisioner() *FakeProvisioner
func (*FakeProvisioner) CollectStatus ¶
func (p *FakeProvisioner) CollectStatus() ([]provision.Unit, error)
func (*FakeProvisioner) DeployPipeline ¶
func (p *FakeProvisioner) DeployPipeline() *action.Pipeline
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 (*FakeProvisioner) ExecutedPipeline ¶
func (p *FakeProvisioner) ExecutedPipeline() bool
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 (*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) 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) 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) Starts ¶
func (p *FakeProvisioner) Starts(app provision.App) int
Starts returns the number of starts for a given app.
func (*FakeProvisioner) UnsetCName ¶
func (p *FakeProvisioner) UnsetCName(app provision.App, cname string) error
type FakeQFactory ¶
func NewFakeQFactory ¶
func NewFakeQFactory() *FakeQFactory
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 (*FakeUnit) GetMachine ¶
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) SetGitConfs ¶
func (*T) StartAmzS3AndIAM ¶
type TestHandler ¶
func (*TestHandler) ServeHTTP ¶
func (h *TestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)