From 9b344945017aa54b91067b86fe9f3a957c213398 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 20 May 2021 10:38:22 +0530 Subject: [PATCH] use mockgen --- .../stores/http_handler_test.go | 133 +++++++------ extern/sector-storage/stores/interface.go | 2 + .../stores/mocks/PartialFileHandler.go | 61 ------ extern/sector-storage/stores/mocks/stores.go | 182 ++++++++++++++++++ extern/sector-storage/stores/remote.go | 4 + go.mod | 2 +- go.sum | 2 + 7 files changed, 261 insertions(+), 125 deletions(-) delete mode 100644 extern/sector-storage/stores/mocks/PartialFileHandler.go create mode 100644 extern/sector-storage/stores/mocks/stores.go diff --git a/extern/sector-storage/stores/http_handler_test.go b/extern/sector-storage/stores/http_handler_test.go index 16703b465..c943e36b6 100644 --- a/extern/sector-storage/stores/http_handler_test.go +++ b/extern/sector-storage/stores/http_handler_test.go @@ -15,7 +15,7 @@ import ( "github.com/filecoin-project/lotus/extern/sector-storage/stores/mocks" "github.com/filecoin-project/lotus/extern/sector-storage/storiface" "github.com/filecoin-project/specs-storage/storage" - "github.com/stretchr/testify/mock" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "golang.org/x/xerrors" ) @@ -62,8 +62,8 @@ func TestRemoteGetAllocated(t *testing.T) { tcs := map[string]struct { piFnc func(pi *pieceInfo) - storeFnc func(s *mocks.Store) - pfFunc func(s *mocks.PartialFileHandler) + storeFnc func(s *mocks.MockStore) + pfFunc func(s *mocks.MockpartialFileHandler) // expectation expectedStatusCode int @@ -100,97 +100,101 @@ func TestRemoteGetAllocated(t *testing.T) { }, "fails when errors out during acquiring unsealed sector file": { expectedStatusCode: http.StatusInternalServerError, - storeFnc: func(l *mocks.Store) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + storeFnc: func(l *mocks.MockStore) { + + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: "path", }, - storiface.SectorPaths{}, xerrors.New("some error")) + storiface.SectorPaths{}, xerrors.New("some error")).Times(1) }, }, "fails when unsealed sector file is not found locally": { expectedStatusCode: http.StatusInternalServerError, - storeFnc: func(l *mocks.Store) { + storeFnc: func(l *mocks.MockStore) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{}, - storiface.SectorPaths{}, nil) + storiface.SectorPaths{}, nil).Times(1) }, }, "fails when partial file is not found locally": { expectedStatusCode: http.StatusInternalServerError, - storeFnc: func(l *mocks.Store) { + storeFnc: func(l *mocks.MockStore) { // will return emppty paths - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: pfPath, }, - storiface.SectorPaths{}, nil) + storiface.SectorPaths{}, nil).Times(1) }, - pfFunc: func(pf *mocks.PartialFileHandler) { + pfFunc: func(pf *mocks.MockpartialFileHandler) { //OpenPartialFile(maxPieceSize abi.PaddedPieceSize, path string) - pf.On("OpenPartialFile", abi.PaddedPieceSize(sectorSize), pfPath).Return(&partialfile.PartialFile{}, - xerrors.New("some error")) + pf.EXPECT().OpenPartialFile(abi.PaddedPieceSize(sectorSize), pfPath).Return(&partialfile.PartialFile{}, + xerrors.New("some error")).Times(1) }, }, "fails when determining partial file allocation returns an error": { expectedStatusCode: http.StatusInternalServerError, - storeFnc: func(l *mocks.Store) { + storeFnc: func(l *mocks.MockStore) { // will return emppty paths - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: pfPath, }, - storiface.SectorPaths{}, nil) + storiface.SectorPaths{}, nil).Times(1) }, - pfFunc: func(pf *mocks.PartialFileHandler) { - pf.On("OpenPartialFile", abi.PaddedPieceSize(sectorSize), pfPath).Return(emptyPartialFile, - nil) - pf.On("HasAllocated", emptyPartialFile, storiface.UnpaddedByteIndex(validOffsetInt), - abi.UnpaddedPieceSize(validSizeInt)).Return(true, xerrors.New("some error")) + pfFunc: func(pf *mocks.MockpartialFileHandler) { + pf.EXPECT().OpenPartialFile(abi.PaddedPieceSize(sectorSize), pfPath).Return(emptyPartialFile, + nil).Times(1) + + pf.EXPECT().HasAllocated(emptyPartialFile, storiface.UnpaddedByteIndex(validOffsetInt), + abi.UnpaddedPieceSize(validSizeInt)).Return(true, xerrors.New("some error")).Times(1) }, }, "StatusRequestedRangeNotSatisfiable when piece is NOT allocated in partial file": { expectedStatusCode: http.StatusRequestedRangeNotSatisfiable, - storeFnc: func(l *mocks.Store) { + storeFnc: func(l *mocks.MockStore) { // will return emppty paths - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: pfPath, }, - storiface.SectorPaths{}, nil) + storiface.SectorPaths{}, nil).Times(1) }, - pfFunc: func(pf *mocks.PartialFileHandler) { - pf.On("OpenPartialFile", abi.PaddedPieceSize(sectorSize), pfPath).Return(emptyPartialFile, - nil) - pf.On("HasAllocated", emptyPartialFile, storiface.UnpaddedByteIndex(validOffsetInt), - abi.UnpaddedPieceSize(validSizeInt)).Return(false, nil) + pfFunc: func(pf *mocks.MockpartialFileHandler) { + pf.EXPECT().OpenPartialFile(abi.PaddedPieceSize(sectorSize), pfPath).Return(emptyPartialFile, + nil).Times(1) + + pf.EXPECT().HasAllocated(emptyPartialFile, storiface.UnpaddedByteIndex(validOffsetInt), + abi.UnpaddedPieceSize(validSizeInt)).Return(false, nil).Times(1) }, }, "OK when piece is allocated in partial file": { expectedStatusCode: http.StatusOK, - storeFnc: func(l *mocks.Store) { + storeFnc: func(l *mocks.MockStore) { // will return emppty paths - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: pfPath, }, - storiface.SectorPaths{}, nil) + storiface.SectorPaths{}, nil).Times(1) }, - pfFunc: func(pf *mocks.PartialFileHandler) { - pf.On("OpenPartialFile", abi.PaddedPieceSize(sectorSize), pfPath).Return(emptyPartialFile, - nil) - pf.On("HasAllocated", emptyPartialFile, storiface.UnpaddedByteIndex(validOffsetInt), - abi.UnpaddedPieceSize(validSizeInt)).Return(true, nil) + pfFunc: func(pf *mocks.MockpartialFileHandler) { + pf.EXPECT().OpenPartialFile(abi.PaddedPieceSize(sectorSize), pfPath).Return(emptyPartialFile, + nil).Times(1) + + pf.EXPECT().HasAllocated(emptyPartialFile, storiface.UnpaddedByteIndex(validOffsetInt), + abi.UnpaddedPieceSize(validSizeInt)).Return(true, nil).Times(1) }, }, } @@ -198,8 +202,13 @@ func TestRemoteGetAllocated(t *testing.T) { for name, tc := range tcs { tc := tc t.Run(name, func(t *testing.T) { - lstore := &mocks.Store{} - pfhandler := &mocks.PartialFileHandler{} + // create go mock controller here + mockCtrl := gomock.NewController(t) + // when test is done, assert expectations on all mock objects. + defer mockCtrl.Finish() + + lstore := mocks.NewMockStore(mockCtrl) + pfhandler := mocks.NewMockpartialFileHandler(mockCtrl) handler := &stores.FetchHandler{ lstore, @@ -239,9 +248,6 @@ func TestRemoteGetAllocated(t *testing.T) { // assert expected status code require.Equal(t, tc.expectedStatusCode, resp.StatusCode) - - // assert expectations on the mocks - lstore.AssertExpectations(t) }) } } @@ -271,7 +277,7 @@ func TestRemoteGetSector(t *testing.T) { tcs := map[string]struct { siFnc func(pi *sectorInfo) - storeFnc func(s *mocks.Store, path string) + storeFnc func(s *mocks.MockStore, path string) // reading a file or a dir isDir bool @@ -297,31 +303,32 @@ func TestRemoteGetSector(t *testing.T) { noResponseBytes: true, }, "fails when error while acquiring sector file": { - storeFnc: func(l *mocks.Store, _ string) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + storeFnc: func(l *mocks.MockStore, _ string) { + + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: "path", }, - storiface.SectorPaths{}, xerrors.New("some error")) + storiface.SectorPaths{}, xerrors.New("some error")).Times(1) }, expectedStatusCode: http.StatusInternalServerError, noResponseBytes: true, }, "fails when acquired sector file path is empty": { expectedStatusCode: http.StatusInternalServerError, - storeFnc: func(l *mocks.Store, _ string) { + storeFnc: func(l *mocks.MockStore, _ string) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{}, - storiface.SectorPaths{}, nil) + storiface.SectorPaths{}, nil).Times(1) }, noResponseBytes: true, }, "fails when acquired file does not exist": { expectedStatusCode: http.StatusInternalServerError, - storeFnc: func(l *mocks.Store, _ string) { + storeFnc: func(l *mocks.MockStore, _ string) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: "path", }, @@ -330,9 +337,9 @@ func TestRemoteGetSector(t *testing.T) { noResponseBytes: true, }, "successfully read a sector file": { - storeFnc: func(l *mocks.Store, path string) { + storeFnc: func(l *mocks.MockStore, path string) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: path, }, @@ -345,9 +352,9 @@ func TestRemoteGetSector(t *testing.T) { expectedResponseBytes: fileBytes, }, "successfully read a sector dir": { - storeFnc: func(l *mocks.Store, path string) { + storeFnc: func(l *mocks.MockStore, path string) { - l.On("AcquireSector", mock.Anything, expectedSectorRef, storiface.FTUnsealed, + l.EXPECT().AcquireSector(gomock.Any(), expectedSectorRef, storiface.FTUnsealed, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove).Return(storiface.SectorPaths{ Unsealed: path, }, @@ -365,6 +372,12 @@ func TestRemoteGetSector(t *testing.T) { for name, tc := range tcs { tc := tc t.Run(name, func(t *testing.T) { + mockCtrl := gomock.NewController(t) + // when test is done, assert expectations on all mock objects. + defer mockCtrl.Finish() + lstore := mocks.NewMockStore(mockCtrl) + pfhandler := mocks.NewMockpartialFileHandler(mockCtrl) + var path string if !tc.isDir { @@ -401,9 +414,6 @@ func TestRemoteGetSector(t *testing.T) { path = tempDir } - lstore := &mocks.Store{} - pfhandler := &mocks.PartialFileHandler{} - handler := &stores.FetchHandler{ lstore, pfhandler, @@ -447,9 +457,6 @@ func TestRemoteGetSector(t *testing.T) { } require.Equal(t, tc.expectedContentType, resp.Header.Get("Content-Type")) - - // assert expectations on the mocks - lstore.AssertExpectations(t) }) } } diff --git a/extern/sector-storage/stores/interface.go b/extern/sector-storage/stores/interface.go index 2c408cb0a..6b970d920 100644 --- a/extern/sector-storage/stores/interface.go +++ b/extern/sector-storage/stores/interface.go @@ -35,4 +35,6 @@ type Store interface { MoveStorage(ctx context.Context, s storage.SectorRef, types storiface.SectorFileType) error FsStat(ctx context.Context, id ID) (fsutil.FsStat, error) + + Reserve(ctx context.Context, sid storage.SectorRef, ft storiface.SectorFileType, storageIDs storiface.SectorPaths, overheadTab map[storiface.SectorFileType]int) (func(), error) } diff --git a/extern/sector-storage/stores/mocks/PartialFileHandler.go b/extern/sector-storage/stores/mocks/PartialFileHandler.go deleted file mode 100644 index d848732d6..000000000 --- a/extern/sector-storage/stores/mocks/PartialFileHandler.go +++ /dev/null @@ -1,61 +0,0 @@ -// Code generated by mockery 2.7.5. DO NOT EDIT. - -package mocks - -import ( - abi "github.com/filecoin-project/go-state-types/abi" - mock "github.com/stretchr/testify/mock" - - partialfile "github.com/filecoin-project/lotus/extern/sector-storage/partialfile" - - storiface "github.com/filecoin-project/lotus/extern/sector-storage/storiface" -) - -// PartialFileHandler is an autogenerated mock type for the PartialFileHandler type -type PartialFileHandler struct { - mock.Mock -} - -// HasAllocated provides a mock function with given fields: pf, offset, size -func (_m *PartialFileHandler) HasAllocated(pf *partialfile.PartialFile, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) (bool, error) { - ret := _m.Called(pf, offset, size) - - var r0 bool - if rf, ok := ret.Get(0).(func(*partialfile.PartialFile, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) bool); ok { - r0 = rf(pf, offset, size) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(*partialfile.PartialFile, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) error); ok { - r1 = rf(pf, offset, size) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// OpenPartialFile provides a mock function with given fields: maxPieceSize, path -func (_m *PartialFileHandler) OpenPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialfile.PartialFile, error) { - ret := _m.Called(maxPieceSize, path) - - var r0 *partialfile.PartialFile - if rf, ok := ret.Get(0).(func(abi.PaddedPieceSize, string) *partialfile.PartialFile); ok { - r0 = rf(maxPieceSize, path) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*partialfile.PartialFile) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(abi.PaddedPieceSize, string) error); ok { - r1 = rf(maxPieceSize, path) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/extern/sector-storage/stores/mocks/stores.go b/extern/sector-storage/stores/mocks/stores.go new file mode 100644 index 000000000..43455b7df --- /dev/null +++ b/extern/sector-storage/stores/mocks/stores.go @@ -0,0 +1,182 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: interface.go + +// Package mock_stores is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + abi "github.com/filecoin-project/go-state-types/abi" + fsutil "github.com/filecoin-project/lotus/extern/sector-storage/fsutil" + partialfile "github.com/filecoin-project/lotus/extern/sector-storage/partialfile" + stores "github.com/filecoin-project/lotus/extern/sector-storage/stores" + storiface "github.com/filecoin-project/lotus/extern/sector-storage/storiface" + storage "github.com/filecoin-project/specs-storage/storage" + gomock "github.com/golang/mock/gomock" +) + +// MockpartialFileHandler is a mock of partialFileHandler interface. +type MockpartialFileHandler struct { + ctrl *gomock.Controller + recorder *MockpartialFileHandlerMockRecorder +} + +// MockpartialFileHandlerMockRecorder is the mock recorder for MockpartialFileHandler. +type MockpartialFileHandlerMockRecorder struct { + mock *MockpartialFileHandler +} + +// NewMockpartialFileHandler creates a new mock instance. +func NewMockpartialFileHandler(ctrl *gomock.Controller) *MockpartialFileHandler { + mock := &MockpartialFileHandler{ctrl: ctrl} + mock.recorder = &MockpartialFileHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockpartialFileHandler) EXPECT() *MockpartialFileHandlerMockRecorder { + return m.recorder +} + +// HasAllocated mocks base method. +func (m *MockpartialFileHandler) HasAllocated(pf *partialfile.PartialFile, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasAllocated", pf, offset, size) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HasAllocated indicates an expected call of HasAllocated. +func (mr *MockpartialFileHandlerMockRecorder) HasAllocated(pf, offset, size interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasAllocated", reflect.TypeOf((*MockpartialFileHandler)(nil).HasAllocated), pf, offset, size) +} + +// OpenPartialFile mocks base method. +func (m *MockpartialFileHandler) OpenPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialfile.PartialFile, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "OpenPartialFile", maxPieceSize, path) + ret0, _ := ret[0].(*partialfile.PartialFile) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// OpenPartialFile indicates an expected call of OpenPartialFile. +func (mr *MockpartialFileHandlerMockRecorder) OpenPartialFile(maxPieceSize, path interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenPartialFile", reflect.TypeOf((*MockpartialFileHandler)(nil).OpenPartialFile), maxPieceSize, path) +} + +// MockStore is a mock of Store interface. +type MockStore struct { + ctrl *gomock.Controller + recorder *MockStoreMockRecorder +} + +// MockStoreMockRecorder is the mock recorder for MockStore. +type MockStoreMockRecorder struct { + mock *MockStore +} + +// NewMockStore creates a new mock instance. +func NewMockStore(ctrl *gomock.Controller) *MockStore { + mock := &MockStore{ctrl: ctrl} + mock.recorder = &MockStoreMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStore) EXPECT() *MockStoreMockRecorder { + return m.recorder +} + +// AcquireSector mocks base method. +func (m *MockStore) AcquireSector(ctx context.Context, s storage.SectorRef, existing, allocate storiface.SectorFileType, sealing storiface.PathType, op storiface.AcquireMode) (storiface.SectorPaths, storiface.SectorPaths, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AcquireSector", ctx, s, existing, allocate, sealing, op) + ret0, _ := ret[0].(storiface.SectorPaths) + ret1, _ := ret[1].(storiface.SectorPaths) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// AcquireSector indicates an expected call of AcquireSector. +func (mr *MockStoreMockRecorder) AcquireSector(ctx, s, existing, allocate, sealing, op interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcquireSector", reflect.TypeOf((*MockStore)(nil).AcquireSector), ctx, s, existing, allocate, sealing, op) +} + +// FsStat mocks base method. +func (m *MockStore) FsStat(ctx context.Context, id stores.ID) (fsutil.FsStat, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FsStat", ctx, id) + ret0, _ := ret[0].(fsutil.FsStat) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FsStat indicates an expected call of FsStat. +func (mr *MockStoreMockRecorder) FsStat(ctx, id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FsStat", reflect.TypeOf((*MockStore)(nil).FsStat), ctx, id) +} + +// MoveStorage mocks base method. +func (m *MockStore) MoveStorage(ctx context.Context, s storage.SectorRef, types storiface.SectorFileType) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MoveStorage", ctx, s, types) + ret0, _ := ret[0].(error) + return ret0 +} + +// MoveStorage indicates an expected call of MoveStorage. +func (mr *MockStoreMockRecorder) MoveStorage(ctx, s, types interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MoveStorage", reflect.TypeOf((*MockStore)(nil).MoveStorage), ctx, s, types) +} + +// Remove mocks base method. +func (m *MockStore) Remove(ctx context.Context, s abi.SectorID, types storiface.SectorFileType, force bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Remove", ctx, s, types, force) + ret0, _ := ret[0].(error) + return ret0 +} + +// Remove indicates an expected call of Remove. +func (mr *MockStoreMockRecorder) Remove(ctx, s, types, force interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockStore)(nil).Remove), ctx, s, types, force) +} + +// RemoveCopies mocks base method. +func (m *MockStore) RemoveCopies(ctx context.Context, s abi.SectorID, types storiface.SectorFileType) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveCopies", ctx, s, types) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveCopies indicates an expected call of RemoveCopies. +func (mr *MockStoreMockRecorder) RemoveCopies(ctx, s, types interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCopies", reflect.TypeOf((*MockStore)(nil).RemoveCopies), ctx, s, types) +} + +// Reserve mocks base method. +func (m *MockStore) Reserve(ctx context.Context, sid storage.SectorRef, ft storiface.SectorFileType, storageIDs storiface.SectorPaths, overheadTab map[storiface.SectorFileType]int) (func(), error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Reserve", ctx, sid, ft, storageIDs, overheadTab) + ret0, _ := ret[0].(func()) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Reserve indicates an expected call of Reserve. +func (mr *MockStoreMockRecorder) Reserve(ctx, sid, ft, storageIDs, overheadTab interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reserve", reflect.TypeOf((*MockStore)(nil).Reserve), ctx, sid, ft, storageIDs, overheadTab) +} diff --git a/extern/sector-storage/stores/remote.go b/extern/sector-storage/stores/remote.go index a09c87761..1a30fac8f 100644 --- a/extern/sector-storage/stores/remote.go +++ b/extern/sector-storage/stores/remote.go @@ -581,4 +581,8 @@ func (r *Remote) Reader(ctx context.Context, s storage.SectorRef, offset, size a return nil, nil } +func (r *Remote) Reserve(ctx context.Context, sid storage.SectorRef, ft storiface.SectorFileType, storageIDs storiface.SectorPaths, overheadTab map[storiface.SectorFileType]int) (func(), error) { + panic("not implemented") +} + var _ Store = &Remote{} diff --git a/go.mod b/go.mod index 9c47ec848..0c2ee70b3 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/gdamore/tcell/v2 v2.2.0 github.com/go-kit/kit v0.10.0 github.com/go-ole/go-ole v1.2.4 // indirect - github.com/golang/mock v1.4.4 + github.com/golang/mock v1.5.0 github.com/google/uuid v1.1.2 github.com/gorilla/mux v1.7.4 github.com/gorilla/websocket v1.4.2 diff --git a/go.sum b/go.sum index f26f4f931..a6bbb22ff 100644 --- a/go.sum +++ b/go.sum @@ -409,6 +409,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=