tests

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(api libmachine.API, name string) bool

Exists tells whether a named host exists.

func MakeTempDir

func MakeTempDir() string

func State

func State(api libmachine.API, name string) state.State

State returns the state of a host.

Types

type MockAPI

type MockAPI struct {
	Hosts       map[string]*host.Host
	CreateError bool
	RemoveError bool
	SaveCalled  bool
}

MockAPI is a struct used to mock out libmachine.API

func NewMockAPI

func NewMockAPI() *MockAPI

func (*MockAPI) Close

func (api *MockAPI) Close() error

Close closes the API.

func (*MockAPI) Create

func (api *MockAPI) Create(h *host.Host) error

Create creates the actual host.

func (*MockAPI) Exists

func (api *MockAPI) Exists(name string) (bool, error)

Exists determines if the host already exists.

func (MockAPI) GetMachinesDir

func (api MockAPI) GetMachinesDir() string

GetMachinesDir returns the directory to store machines in.

func (*MockAPI) List

func (api *MockAPI) List() ([]string, error)

List the existing hosts.

func (*MockAPI) Load

func (api *MockAPI) Load(name string) (*host.Host, error)

Load loads a host from disk.

func (*MockAPI) NewHost

func (api *MockAPI) NewHost(driverName string, rawDriver []byte) (*host.Host, error)

NewHost creates a new host.Host instance.

func (*MockAPI) Remove

func (api *MockAPI) Remove(name string) error

Remove a host.

func (*MockAPI) Save

func (api *MockAPI) Save(host *host.Host) error

Save saves a host to disk.

type MockDriver

type MockDriver struct {
	drivers.BaseDriver
	CurrentState state.State
	RemoveError  bool
	HostError    bool
	Port         int
}

MockDriver is a struct used to mock out libmachine.Driver

func (*MockDriver) Create

func (driver *MockDriver) Create() error

Create creates a MockDriver instance

func (*MockDriver) GetCreateFlags

func (driver *MockDriver) GetCreateFlags() []mcnflag.Flag

GetCreateFlags returns the flags used to create a MockDriver

func (*MockDriver) GetIP

func (driver *MockDriver) GetIP() (string, error)

func (*MockDriver) GetSSHHostname

func (driver *MockDriver) GetSSHHostname() (string, error)

GetSSHHostname returns the hostname for SSH

func (*MockDriver) GetSSHKeyPath

func (driver *MockDriver) GetSSHKeyPath() string

GetSSHHostname returns the hostname for SSH

func (*MockDriver) GetSSHPort

func (driver *MockDriver) GetSSHPort() (int, error)

func (*MockDriver) GetState

func (driver *MockDriver) GetState() (state.State, error)

GetState returns the state of the driver

func (*MockDriver) GetURL

func (driver *MockDriver) GetURL() (string, error)

GetURL returns the URL of the driver

func (*MockDriver) Kill

func (driver *MockDriver) Kill() error

Kill kills the machine

func (*MockDriver) Remove

func (driver *MockDriver) Remove() error

Remove removes the machine

func (*MockDriver) Restart

func (driver *MockDriver) Restart() error

Restart restarts the machine

func (*MockDriver) SetConfigFromFlags

func (driver *MockDriver) SetConfigFromFlags(opts drivers.DriverOptions) error

SetConfigFromFlags sets the machine config

func (*MockDriver) Start

func (driver *MockDriver) Start() error

Start starts the machine

func (*MockDriver) Stop

func (driver *MockDriver) Stop() error

Stop stops the machine

type SSHServer

type SSHServer struct {
	Config *ssh.ServerConfig
	// Commands stores the raw commands executed against the server.
	Commands             map[string]int
	Connected            bool
	Transfers            *bytes.Buffer
	HadASessionRequested bool
}

SSHServer provides a mock SSH Server for testing. Commands are stored, not executed.

func NewSSHServer

func NewSSHServer() (*SSHServer, error)

NewSSHServer returns a NewSSHServer instance, ready for use.

func (*SSHServer) Start

func (s *SSHServer) Start() (int, error)

Start starts the mock SSH Server, and returns the port it's listening on.

Jump to

Keyboard shortcuts

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