cli icon indicating copy to clipboard operation
cli copied to clipboard

feat(network/test): Reduce duplicated code

Open Pantani opened this issue 3 years ago • 1 comments

We can use more table tests in the network methods and avoid calling the queryMock too much time. We should define a structure to carry the expected mock and call only one time in the tests.

type mocks struct {
	coordByAddr profiletypes.QueryGetCoordinatorByAddressRequest
	createChain launchtypes.MsgCreateChain
	...
}

suite.ProfileQueryMock.
On(
	"CoordinatorByAddress",
	context.Background(),
	tt.mocks.coordByAddr,
).
Return(nil, nil).
Once()

Pantani avatar May 02 '22 19:05 Pantani

You mean adding fixtures inside of the suite struct? If so I like the idea👌

ivanovpetr avatar May 03 '22 08:05 ivanovpetr