mock_p2p

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: 7 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_p2p 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) EXPECT

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

func (*MockInterface) FetchMostRecentStateBlock

func (m *MockInterface) FetchMostRecentStateBlock(imageHash string, block *mainchain.Block) (*statechain.Block, error)

FetchMostRecentStateBlock mocks base method

func (*MockInterface) GetMainchainBlock

func (m *MockInterface) GetMainchainBlock(c *go_cid.Cid) (*mainchain.Block, error)

GetMainchainBlock mocks base method

func (*MockInterface) GetMerkleTree

func (m *MockInterface) GetMerkleTree(c *go_cid.Cid) (*merkle.Tree, error)

GetMerkleTree mocks base method

func (*MockInterface) GetStatechainBlock

func (m *MockInterface) GetStatechainBlock(c *go_cid.Cid) (*statechain.Block, error)

GetStatechainBlock mocks base method

func (*MockInterface) GetStatechainDiff

func (m *MockInterface) GetStatechainDiff(c *go_cid.Cid) (*statechain.Diff, error)

GetStatechainDiff mocks base method

func (*MockInterface) GetStatechainTransaction

func (m *MockInterface) GetStatechainTransaction(c *go_cid.Cid) (*statechain.Transaction, error)

GetStatechainTransaction mocks base method

func (*MockInterface) Props

func (m *MockInterface) Props() p2p.Props

Props mocks base method

func (*MockInterface) Set

func (m *MockInterface) Set(v interface{}) (*go_cid.Cid, error)

Set mocks base method

func (*MockInterface) SetMainchainBlock

func (m *MockInterface) SetMainchainBlock(block *mainchain.Block) (*go_cid.Cid, error)

SetMainchainBlock mocks base method

func (*MockInterface) SetMerkleTree

func (m *MockInterface) SetMerkleTree(tree *merkle.Tree) (*go_cid.Cid, error)

SetMerkleTree mocks base method

func (*MockInterface) SetStatechainBlock

func (m *MockInterface) SetStatechainBlock(block *statechain.Block) (*go_cid.Cid, error)

SetStatechainBlock mocks base method

func (*MockInterface) SetStatechainDiff

func (m *MockInterface) SetStatechainDiff(d *statechain.Diff) (*go_cid.Cid, error)

SetStatechainDiff mocks base method

func (*MockInterface) SetStatechainTransaction

func (m *MockInterface) SetStatechainTransaction(tx *statechain.Transaction) (*go_cid.Cid, error)

SetStatechainTransaction mocks base method

type MockInterfaceMockRecorder

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

MockInterfaceMockRecorder is the mock recorder for MockInterface

func (*MockInterfaceMockRecorder) FetchMostRecentStateBlock

func (mr *MockInterfaceMockRecorder) FetchMostRecentStateBlock(imageHash, block interface{}) *gomock.Call

FetchMostRecentStateBlock indicates an expected call of FetchMostRecentStateBlock

func (*MockInterfaceMockRecorder) GetMainchainBlock

func (mr *MockInterfaceMockRecorder) GetMainchainBlock(c interface{}) *gomock.Call

GetMainchainBlock indicates an expected call of GetMainchainBlock

func (*MockInterfaceMockRecorder) GetMerkleTree

func (mr *MockInterfaceMockRecorder) GetMerkleTree(c interface{}) *gomock.Call

GetMerkleTree indicates an expected call of GetMerkleTree

func (*MockInterfaceMockRecorder) GetStatechainBlock

func (mr *MockInterfaceMockRecorder) GetStatechainBlock(c interface{}) *gomock.Call

GetStatechainBlock indicates an expected call of GetStatechainBlock

func (*MockInterfaceMockRecorder) GetStatechainDiff

func (mr *MockInterfaceMockRecorder) GetStatechainDiff(c interface{}) *gomock.Call

GetStatechainDiff indicates an expected call of GetStatechainDiff

func (*MockInterfaceMockRecorder) GetStatechainTransaction

func (mr *MockInterfaceMockRecorder) GetStatechainTransaction(c interface{}) *gomock.Call

GetStatechainTransaction indicates an expected call of GetStatechainTransaction

func (*MockInterfaceMockRecorder) Props

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

Props indicates an expected call of Props

func (*MockInterfaceMockRecorder) Set

func (mr *MockInterfaceMockRecorder) Set(v interface{}) *gomock.Call

Set indicates an expected call of Set

func (*MockInterfaceMockRecorder) SetMainchainBlock

func (mr *MockInterfaceMockRecorder) SetMainchainBlock(block interface{}) *gomock.Call

SetMainchainBlock indicates an expected call of SetMainchainBlock

func (*MockInterfaceMockRecorder) SetMerkleTree

func (mr *MockInterfaceMockRecorder) SetMerkleTree(tree interface{}) *gomock.Call

SetMerkleTree indicates an expected call of SetMerkleTree

func (*MockInterfaceMockRecorder) SetStatechainBlock

func (mr *MockInterfaceMockRecorder) SetStatechainBlock(block interface{}) *gomock.Call

SetStatechainBlock indicates an expected call of SetStatechainBlock

func (*MockInterfaceMockRecorder) SetStatechainDiff

func (mr *MockInterfaceMockRecorder) SetStatechainDiff(d interface{}) *gomock.Call

SetStatechainDiff indicates an expected call of SetStatechainDiff

func (*MockInterfaceMockRecorder) SetStatechainTransaction

func (mr *MockInterfaceMockRecorder) SetStatechainTransaction(tx interface{}) *gomock.Call

SetStatechainTransaction indicates an expected call of SetStatechainTransaction

Jump to

Keyboard shortcuts

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