mock_registry

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: 3 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_registry 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) DownloadImage

func (m *MockInterface) DownloadImage(ipfsHash string) (string, error)

DownloadImage mocks base method

func (*MockInterface) EXPECT

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

func (*MockInterface) PullImage

func (m *MockInterface) PullImage(ipfsHash string) (string, error)

PullImage mocks base method

func (*MockInterface) PushImage

func (m *MockInterface) PushImage(reader io.Reader) (string, error)

PushImage mocks base method

func (*MockInterface) PushImageByID

func (m *MockInterface) PushImageByID(imageID string) (string, error)

PushImageByID mocks base method

type MockInterfaceMockRecorder

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

MockInterfaceMockRecorder is the mock recorder for MockInterface

func (*MockInterfaceMockRecorder) DownloadImage

func (mr *MockInterfaceMockRecorder) DownloadImage(ipfsHash interface{}) *gomock.Call

DownloadImage indicates an expected call of DownloadImage

func (*MockInterfaceMockRecorder) PullImage

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

PullImage indicates an expected call of PullImage

func (*MockInterfaceMockRecorder) PushImage

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

PushImage indicates an expected call of PushImage

func (*MockInterfaceMockRecorder) PushImageByID

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

PushImageByID indicates an expected call of PushImageByID

Jump to

Keyboard shortcuts

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