package mockcore

import "github.com/Microsoft/opengcs/service/gcs/core/mockcore"

Package mockcore defines a mock implementation of the Core interface.

Index

Constants

const (
	// Success specifies method calls should succeed.
	Success = iota
	// Error specifies method calls should return an error.
	Error
	// SingleSuccess specifies that the first method call should succeed and additional
	// calls should return an error.
	SingleSuccess
)

Types

type Behavior

type Behavior int

Behavior describes the behavior of the mock core when a method is called.

type CreateContainerCall

type CreateContainerCall struct {
	ID       string
	Settings prot.VMHostedContainerSettings
}

CreateContainerCall captures the arguments of CreateContainer.

type ExecProcessCall

type ExecProcessCall struct {
	ID       string
	Params   prot.ProcessParameters
	StdioSet *stdio.ConnectionSet
}

ExecProcessCall captures the arguments of ExecProcess.

type ListProcessesCall

type ListProcessesCall struct {
	ID string
}

ListProcessesCall captures the arguments of ListProcesses.

type MockCore

type MockCore struct {
	Behavior               Behavior
	LastCreateContainer    CreateContainerCall
	LastExecProcess        ExecProcessCall
	LastSignalContainer    SignalContainerCall
	LastSignalProcess      SignalProcessCall
	LastListProcesses      ListProcessesCall
	LastRunExternalProcess RunExternalProcessCall
	LastModifySettings     ModifySettingsCall
	LastResizeConsole      ResizeConsoleCall
	LastWaitContainer      WaitContainerCall
	LastWaitProcess        WaitProcessCall
	WaitContainerWg        sync.WaitGroup
}

MockCore serves as an argument capture mechanism which implements the Core interface. Arguments passed to one of its methods are stored to be queried later.

func (*MockCore) CreateContainer

func (c *MockCore) CreateContainer(id string, settings prot.VMHostedContainerSettings) error

CreateContainer captures its arguments.

func (*MockCore) ExecProcess

func (c *MockCore) ExecProcess(id string, params prot.ProcessParameters, stdioSet *stdio.ConnectionSet) (pid int, err error)

ExecProcess captures its arguments and returns pid 101.

func (*MockCore) ListProcesses

func (c *MockCore) ListProcesses(id string) ([]runtime.ContainerProcessState, error)

ListProcesses captures its arguments. It then returns a process with pid 101, command "sh -c testexe", CreatedByRuntime true, and IsZombie true.

func (*MockCore) ModifySettings

func (c *MockCore) ModifySettings(id string, request prot.ResourceModificationRequestResponse) error

ModifySettings captures its arguments.

func (*MockCore) ResizeConsole

func (c *MockCore) ResizeConsole(pid int, height, width uint16) error

ResizeConsole captures its arguments and returns a nil error.

func (*MockCore) RunExternalProcess

func (c *MockCore) RunExternalProcess(params prot.ProcessParameters, stdioSet *stdio.ConnectionSet) (pid int, err error)

RunExternalProcess captures its arguments and returns pid 101.

func (*MockCore) SignalContainer

func (c *MockCore) SignalContainer(id string, signal oslayer.Signal) error

SignalContainer captures its arguments.

func (*MockCore) SignalProcess

func (c *MockCore) SignalProcess(pid int, options prot.SignalProcessOptions) error

SignalProcess captures its arguments.

func (*MockCore) WaitContainer

func (c *MockCore) WaitContainer(id string) (int, error)

WaitContainer captures its arguments and returns a nil error.

func (*MockCore) WaitProcess

func (c *MockCore) WaitProcess(pid int) (int, error)

WaitProcess captures its arguments and returns a nil error.

type ModifySettingsCall

type ModifySettingsCall struct {
	ID      string
	Request prot.ResourceModificationRequestResponse
}

ModifySettingsCall captures the arguments of ModifySettings.

type ResizeConsoleCall

type ResizeConsoleCall struct {
	Pid    int
	Height uint16
	Width  uint16
}

ResizeConsoleCall captures the arguments of ResizeConsole

type RunExternalProcessCall

type RunExternalProcessCall struct {
	Params   prot.ProcessParameters
	StdioSet *stdio.ConnectionSet
}

RunExternalProcessCall captures the arguments of RunExternalProcess.

type SignalContainerCall

type SignalContainerCall struct {
	ID     string
	Signal oslayer.Signal
}

SignalContainerCall captures the arguments of SignalContainer.

type SignalProcessCall

type SignalProcessCall struct {
	Pid     int
	Options prot.SignalProcessOptions
}

SignalProcessCall captures the arguments of SignalProcess.

type WaitContainerCall

type WaitContainerCall struct {
	ID string
}

WaitContainerCall captures the arguments of WaitContainer

type WaitProcessCall

type WaitProcessCall struct {
	Pid int
}

WaitProcessCall captures the arguments of WaitProcess

Source Files

mockcore.go

Version
v0.3.4
Published
Sep 13, 2017
Platform
windows/amd64
Imports
6 packages
Last checked
1 minute ago

Tools for package owners.