mock_docker

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

Mock

Install

$ go get github.com/golang/mock/gomock
$ go install github.com/golang/mock/mockgen

Usage

In the main package directory: $ mockgen -source=interface.go -destination=mock/mock.go

Testing

func foo(p2pSvc ptp.Interface) (*statechain.Diff, error) {
  // foo does stuff, here...
}

func TestFoo(t *testing.T) {
	// 1. mock the p2p service
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()

  mockP2P := mock_p2p.NewMockInterface(mockCtrl)
	mockP2P.
		EXPECT().
		GetStatechainDiff(gomock.Any()).
		Return(diff, nil)

	mockP2P.
		EXPECT().
		GetStatechainBlock(gomock.Any()).
		Return(block, nil)

	mockP2P.
		EXPECT().
		GetStatechainDiff(gomock.Any()).
		Return(diff, nil)

	mockP2P.
		EXPECT().
		GetStatechainBlock(gomock.Any()).
		Return(genesisBlock, nil)

	mockP2P.
		EXPECT().
		GetStatechainDiff(gomock.Any()).
		Return(diff, nil)

	// 2. run the function
	diffs, err := foo(mockP2P)
	if err != nil {
		t.Fatal(err)
  }
    
  // etc...
} 

Documentation

Overview

Package mock_docker is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockInterface

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

MockInterface is a mock of Interface interface

func NewMockInterface

func NewMockInterface(ctrl *gomock.Controller) *MockInterface

NewMockInterface creates a new mock instance

func (*MockInterface) ContainerExec

func (m *MockInterface) ContainerExec(containerID string, cmd []string) (io.Reader, error)

ContainerExec mocks base method

func (*MockInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockInterface) InspectContainer

func (m *MockInterface) InspectContainer(containerID string) (types.ContainerJSON, error)

InspectContainer mocks base method

func (*MockInterface) ListImages

func (m *MockInterface) ListImages() ([]*docker.ImageSummary, error)

ListImages mocks base method

func (*MockInterface) LoadImage

func (m *MockInterface) LoadImage(input io.Reader) error

LoadImage mocks base method

func (*MockInterface) LoadImageByFilepath

func (m *MockInterface) LoadImageByFilepath(filepath string) error

LoadImageByFilepath mocks base method

func (*MockInterface) PullImage

func (m *MockInterface) PullImage(imageID string) error

PullImage mocks base method

func (*MockInterface) PushImage

func (m *MockInterface) PushImage(imageID string) error

PushImage mocks base method

func (*MockInterface) ReadImage

func (m *MockInterface) ReadImage(imageID string) (io.Reader, error)

ReadImage mocks base method

func (*MockInterface) RunContainer

func (m *MockInterface) RunContainer(imageID string, cmd []string, config *docker.RunContainerConfig) (string, error)

RunContainer mocks base method

func (*MockInterface) StopContainer

func (m *MockInterface) StopContainer(containerID string) error

StopContainer mocks base method

type MockInterfaceMockRecorder

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

MockInterfaceMockRecorder is the mock recorder for MockInterface

func (*MockInterfaceMockRecorder) ContainerExec

func (mr *MockInterfaceMockRecorder) ContainerExec(containerID, cmd interface{}) *gomock.Call

ContainerExec indicates an expected call of ContainerExec

func (*MockInterfaceMockRecorder) InspectContainer

func (mr *MockInterfaceMockRecorder) InspectContainer(containerID interface{}) *gomock.Call

InspectContainer indicates an expected call of InspectContainer

func (*MockInterfaceMockRecorder) ListImages

func (mr *MockInterfaceMockRecorder) ListImages() *gomock.Call

ListImages indicates an expected call of ListImages

func (*MockInterfaceMockRecorder) LoadImage

func (mr *MockInterfaceMockRecorder) LoadImage(input interface{}) *gomock.Call

LoadImage indicates an expected call of LoadImage

func (*MockInterfaceMockRecorder) LoadImageByFilepath

func (mr *MockInterfaceMockRecorder) LoadImageByFilepath(filepath interface{}) *gomock.Call

LoadImageByFilepath indicates an expected call of LoadImageByFilepath

func (*MockInterfaceMockRecorder) PullImage

func (mr *MockInterfaceMockRecorder) PullImage(imageID interface{}) *gomock.Call

PullImage indicates an expected call of PullImage

func (*MockInterfaceMockRecorder) PushImage

func (mr *MockInterfaceMockRecorder) PushImage(imageID interface{}) *gomock.Call

PushImage indicates an expected call of PushImage

func (*MockInterfaceMockRecorder) ReadImage

func (mr *MockInterfaceMockRecorder) ReadImage(imageID interface{}) *gomock.Call

ReadImage indicates an expected call of ReadImage

func (*MockInterfaceMockRecorder) RunContainer

func (mr *MockInterfaceMockRecorder) RunContainer(imageID, cmd, config interface{}) *gomock.Call

RunContainer indicates an expected call of RunContainer

func (*MockInterfaceMockRecorder) StopContainer

func (mr *MockInterfaceMockRecorder) StopContainer(containerID interface{}) *gomock.Call

StopContainer indicates an expected call of StopContainer

Jump to

Keyboard shortcuts

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