From 05be5372b3084f487d3ece6d7322ae2e05b0e4bb Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 19 Jun 2023 18:56:38 +0300 Subject: [PATCH] Fix failing tests for 'flow blocks get' command --- flowkit/mocks/Services.go | 17 +++++------------ internal/blocks/blocks_test.go | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/flowkit/mocks/Services.go b/flowkit/mocks/Services.go index 3ca4bf838..b86633cc0 100644 --- a/flowkit/mocks/Services.go +++ b/flowkit/mocks/Services.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.2. DO NOT EDIT. +// Code generated by mockery v2.30.1. DO NOT EDIT. package mocks @@ -444,12 +444,6 @@ func (_m *Services) GetTransactionsByBlockID(_a0 context.Context, _a1 flow.Ident } } - if rf, ok := ret.Get(2).(func(context.Context, flow.Identifier) error); ok { - r2 = rf(_a0, _a1) - } else { - r2 = ret.Error(2) - } - return r0, r1, r2 } @@ -608,13 +602,12 @@ func (_m *Services) SignTransactionPayload(_a0 context.Context, _a1 *accounts.Ac return r0, r1 } -type mockConstructorTestingTNewServices interface { +// NewServices creates a new instance of Services. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewServices(t interface { mock.TestingT Cleanup(func()) -} - -// NewServices creates a new instance of Services. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewServices(t mockConstructorTestingTNewServices) *Services { +}) *Services { mock := &Services{} mock.Mock.Test(t) diff --git a/internal/blocks/blocks_test.go b/internal/blocks/blocks_test.go index 04f6dd12d..783cfcfb6 100644 --- a/internal/blocks/blocks_test.go +++ b/internal/blocks/blocks_test.go @@ -46,11 +46,27 @@ func Test_GetBlock(t *testing.T) { assert.Equal(t, uint64(100), args.Get(3).(uint64)) }).Return(nil, nil) - srv.GetCollection.Return(nil, nil) + returnCollection := tests.NewCollection() + transaction1 := tests.NewTransaction() + transaction2 := tests.NewTransaction() + returnCollection.TransactionIDs = []flow.Identifier{ + transaction1.ID(), + transaction2.ID(), + } + transactions := []*flow.Transaction{ + transaction1, + transaction2, + } returnBlock := tests.NewBlock() returnBlock.Height = uint64(100) + srv.GetTransactionsByBlockID.Run(func(args mock.Arguments) { + assert.Equal(t, returnBlock.ID, args.Get(1).(flow.Identifier)) + }).Return(transactions, nil) + + srv.GetCollection.Return(returnCollection, nil) + srv.GetBlock.Run(func(args mock.Arguments) { assert.Equal(t, uint64(100), args.Get(1).(flowkit.BlockQuery).Height) }).Return(returnBlock, nil)