From 38a1a22f0c0c14c3ae63e6a2e97e05d9b09797c8 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Fri, 30 Sep 2022 15:53:33 +0200 Subject: [PATCH] Move mocks to separate packages --- .../mock_cache.go} | 9 ++-- common/commonspace/cache/treecache.go | 2 +- .../diffservice/diffsyncer_test.go | 49 +++++++++++++++---- .../mock_spacesyncproto.go} | 17 ++++--- .../commonspace/spacesyncproto/spacesync.go | 2 +- .../mock_storage.go} | 13 ++--- common/commonspace/storage/storage.go | 2 +- common/nodeconf/configuration.go | 2 +- .../mock_nodeconf.go} | 4 +- pkg/acl/list/list.go | 2 +- .../{list_mock.go => mock_list/mock_list.go} | 25 +++++----- pkg/acl/storage/liststorage.go | 2 +- .../mock_storage.go} | 4 +- .../mock_objecttree.go} | 21 ++++---- pkg/acl/tree/objecttree.go | 2 +- pkg/ldiff/diff.go | 2 +- .../mock_ldiff.go} | 17 ++++--- 17 files changed, 105 insertions(+), 70 deletions(-) rename common/commonspace/cache/{treecache_mock.go => mock_cache/mock_cache.go} (93%) rename common/commonspace/spacesyncproto/{drpcspaceclient_mock.go => mock_spacesyncproto/mock_spacesyncproto.go} (82%) rename common/commonspace/storage/{storage_mock.go => mock_storage/mock_storage.go} (93%) rename common/nodeconf/{configuration_mock.go => mock_nodeconf/mock_nodeconf.go} (98%) rename pkg/acl/list/{list_mock.go => mock_list/mock_list.go} (90%) rename pkg/acl/storage/{liststorage_mock.go => mock_storage/mock_storage.go} (97%) rename pkg/acl/tree/{objecttree_mock.go => mock_objecttree/mock_objecttree.go} (93%) rename pkg/ldiff/{diff_mock.go => mock_ldiff/mock_ldiff.go} (85%) diff --git a/common/commonspace/cache/treecache_mock.go b/common/commonspace/cache/mock_cache/mock_cache.go similarity index 93% rename from common/commonspace/cache/treecache_mock.go rename to common/commonspace/cache/mock_cache/mock_cache.go index 1a42b411..84822cdb 100644 --- a/common/commonspace/cache/treecache_mock.go +++ b/common/commonspace/cache/mock_cache/mock_cache.go @@ -1,14 +1,15 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache (interfaces: TreeCache) -// Package cache is a generated GoMock package. -package cache +// Package mock_cache is a generated GoMock package. +package mock_cache import ( context "context" reflect "reflect" app "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + cache "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" gomock "github.com/golang/mock/gomock" ) @@ -50,10 +51,10 @@ func (mr *MockTreeCacheMockRecorder) Close(arg0 interface{}) *gomock.Call { } // GetTree mocks base method. -func (m *MockTreeCache) GetTree(arg0 context.Context, arg1, arg2 string) (TreeResult, error) { +func (m *MockTreeCache) GetTree(arg0 context.Context, arg1, arg2 string) (cache.TreeResult, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetTree", arg0, arg1, arg2) - ret0, _ := ret[0].(TreeResult) + ret0, _ := ret[0].(cache.TreeResult) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go index 4f72f0fd..274f044a 100644 --- a/common/commonspace/cache/treecache.go +++ b/common/commonspace/cache/treecache.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package cache -destination treecache_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache TreeCache +//go:generate mockgen -destination mock_cache/mock_cache.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache TreeCache package cache import ( diff --git a/common/commonspace/diffservice/diffsyncer_test.go b/common/commonspace/diffservice/diffsyncer_test.go index 70a849d0..211aecb7 100644 --- a/common/commonspace/diffservice/diffsyncer_test.go +++ b/common/commonspace/diffservice/diffsyncer_test.go @@ -4,14 +4,16 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache/mock_cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto/mock_spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage/mock_storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf/mock_nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" - storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" + mock_aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage/mock_storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff/mock_ldiff" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "storj.io/drpc" @@ -54,11 +56,11 @@ func TestDiffSyncer_Sync(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - diffMock := ldiff.NewMockDiff(ctrl) - nconfMock := nodeconf.NewMockConfiguration(ctrl) - cacheMock := cache.NewMockTreeCache(ctrl) - stMock := storage.NewMockSpaceStorage(ctrl) - clientMock := spacesyncproto.NewMockDRPCSpaceClient(ctrl) + diffMock := mock_ldiff.NewMockDiff(ctrl) + nconfMock := mock_nodeconf.NewMockConfiguration(ctrl) + cacheMock := mock_cache.NewMockTreeCache(ctrl) + stMock := mock_storage.NewMockSpaceStorage(ctrl) + clientMock := mock_spacesyncproto.NewMockDRPCSpaceClient(ctrl) factory := spacesyncproto.ClientFactoryFunc(func(cc drpc.Conn) spacesyncproto.DRPCSpaceClient { return clientMock }) @@ -82,7 +84,34 @@ func TestDiffSyncer_Sync(t *testing.T) { }) t.Run("diff syncer sync space missing", func(t *testing.T) { - aclStorageMock := storage2.NewMockListStorage(ctrl) + aclStorageMock := mock_aclstorage.NewMockListStorage(ctrl) + aclRoot := &aclrecordproto.RawACLRecordWithId{} + spaceHeader := &spacesyncproto.SpaceHeader{} + + nconfMock.EXPECT(). + ResponsiblePeers(gomock.Any(), spaceId). + Return([]peer.Peer{nil}, nil) + diffMock.EXPECT(). + Diff(gomock.Any(), gomock.Eq(remotediff.NewRemoteDiff(spaceId, clientMock))). + Return(nil, nil, nil, spacesyncproto.ErrSpaceMissing) + stMock.EXPECT(). + ACLStorage(). + Return(aclStorageMock, nil) + stMock.EXPECT(). + SpaceHeader(). + Return(spaceHeader, nil) + aclStorageMock.EXPECT(). + Root(). + Return(aclRoot, nil) + clientMock.EXPECT(). + PushSpace(gomock.Any(), newPushSpaceRequestMatcher(spaceId, aclRoot, spaceHeader)). + Return(nil, nil) + + require.NoError(t, diffSyncer.Sync(ctx)) + }) + + t.Run("diff syncer sync space missing", func(t *testing.T) { + aclStorageMock := mock_aclstorage.NewMockListStorage(ctrl) aclRoot := &aclrecordproto.RawACLRecordWithId{} spaceHeader := &spacesyncproto.SpaceHeader{} diff --git a/common/commonspace/spacesyncproto/drpcspaceclient_mock.go b/common/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go similarity index 82% rename from common/commonspace/spacesyncproto/drpcspaceclient_mock.go rename to common/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go index 4e8fd108..0d0d52c5 100644 --- a/common/commonspace/spacesyncproto/drpcspaceclient_mock.go +++ b/common/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go @@ -1,13 +1,14 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto (interfaces: DRPCSpaceClient) -// Package spacesyncproto is a generated GoMock package. -package spacesyncproto +// Package mock_spacesyncproto is a generated GoMock package. +package mock_spacesyncproto import ( context "context" reflect "reflect" + spacesyncproto "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" gomock "github.com/golang/mock/gomock" drpc "storj.io/drpc" ) @@ -50,10 +51,10 @@ func (mr *MockDRPCSpaceClientMockRecorder) DRPCConn() *gomock.Call { } // HeadSync mocks base method. -func (m *MockDRPCSpaceClient) HeadSync(arg0 context.Context, arg1 *HeadSyncRequest) (*HeadSyncResponse, error) { +func (m *MockDRPCSpaceClient) HeadSync(arg0 context.Context, arg1 *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "HeadSync", arg0, arg1) - ret0, _ := ret[0].(*HeadSyncResponse) + ret0, _ := ret[0].(*spacesyncproto.HeadSyncResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -65,10 +66,10 @@ func (mr *MockDRPCSpaceClientMockRecorder) HeadSync(arg0, arg1 interface{}) *gom } // PushSpace mocks base method. -func (m *MockDRPCSpaceClient) PushSpace(arg0 context.Context, arg1 *PushSpaceRequest) (*PushSpaceResponse, error) { +func (m *MockDRPCSpaceClient) PushSpace(arg0 context.Context, arg1 *spacesyncproto.PushSpaceRequest) (*spacesyncproto.PushSpaceResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PushSpace", arg0, arg1) - ret0, _ := ret[0].(*PushSpaceResponse) + ret0, _ := ret[0].(*spacesyncproto.PushSpaceResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -80,10 +81,10 @@ func (mr *MockDRPCSpaceClientMockRecorder) PushSpace(arg0, arg1 interface{}) *go } // Stream mocks base method. -func (m *MockDRPCSpaceClient) Stream(arg0 context.Context) (DRPCSpace_StreamClient, error) { +func (m *MockDRPCSpaceClient) Stream(arg0 context.Context) (spacesyncproto.DRPCSpace_StreamClient, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Stream", arg0) - ret0, _ := ret[0].(DRPCSpace_StreamClient) + ret0, _ := ret[0].(spacesyncproto.DRPCSpace_StreamClient) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/common/commonspace/spacesyncproto/spacesync.go b/common/commonspace/spacesyncproto/spacesync.go index e7924694..068642fe 100644 --- a/common/commonspace/spacesyncproto/spacesync.go +++ b/common/commonspace/spacesyncproto/spacesync.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package spacesyncproto -destination drpcspaceclient_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto DRPCSpaceClient +//go:generate mockgen -destination mock_spacesyncproto/mock_spacesyncproto.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto DRPCSpaceClient package spacesyncproto import ( diff --git a/common/commonspace/storage/storage_mock.go b/common/commonspace/storage/mock_storage/mock_storage.go similarity index 93% rename from common/commonspace/storage/storage_mock.go rename to common/commonspace/storage/mock_storage/mock_storage.go index c671fbad..14b6003f 100644 --- a/common/commonspace/storage/storage_mock.go +++ b/common/commonspace/storage/mock_storage/mock_storage.go @@ -1,14 +1,15 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage (interfaces: SpaceStorageProvider,SpaceStorage) -// Package storage is a generated GoMock package. -package storage +// Package mock_storage is a generated GoMock package. +package mock_storage import ( reflect "reflect" app "github.com/anytypeio/go-anytype-infrastructure-experiments/app" spacesyncproto "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" storage0 "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" gomock "github.com/golang/mock/gomock" ) @@ -37,10 +38,10 @@ func (m *MockSpaceStorageProvider) EXPECT() *MockSpaceStorageProviderMockRecorde } // CreateSpaceStorage mocks base method. -func (m *MockSpaceStorageProvider) CreateSpaceStorage(arg0 SpaceStorageCreatePayload) (SpaceStorage, error) { +func (m *MockSpaceStorageProvider) CreateSpaceStorage(arg0 storage.SpaceStorageCreatePayload) (storage.SpaceStorage, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateSpaceStorage", arg0) - ret0, _ := ret[0].(SpaceStorage) + ret0, _ := ret[0].(storage.SpaceStorage) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -80,10 +81,10 @@ func (mr *MockSpaceStorageProviderMockRecorder) Name() *gomock.Call { } // SpaceStorage mocks base method. -func (m *MockSpaceStorageProvider) SpaceStorage(arg0 string) (SpaceStorage, error) { +func (m *MockSpaceStorageProvider) SpaceStorage(arg0 string) (storage.SpaceStorage, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SpaceStorage", arg0) - ret0, _ := ret[0].(SpaceStorage) + ret0, _ := ret[0].(storage.SpaceStorage) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index 60d852e6..fc1cfa8d 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package storage -destination storage_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage SpaceStorageProvider,SpaceStorage +//go:generate mockgen -destination mock_storage/mock_storage.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage SpaceStorageProvider,SpaceStorage package storage import ( diff --git a/common/nodeconf/configuration.go b/common/nodeconf/configuration.go index cb169103..8e50303b 100644 --- a/common/nodeconf/configuration.go +++ b/common/nodeconf/configuration.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package nodeconf -destination configuration_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf Configuration +//go:generate mockgen -destination mock_nodeconf/mock_nodeconf.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf Configuration package nodeconf import ( diff --git a/common/nodeconf/configuration_mock.go b/common/nodeconf/mock_nodeconf/mock_nodeconf.go similarity index 98% rename from common/nodeconf/configuration_mock.go rename to common/nodeconf/mock_nodeconf/mock_nodeconf.go index c84e1848..e65895eb 100644 --- a/common/nodeconf/configuration_mock.go +++ b/common/nodeconf/mock_nodeconf/mock_nodeconf.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf (interfaces: Configuration) -// Package nodeconf is a generated GoMock package. -package nodeconf +// Package mock_nodeconf is a generated GoMock package. +package mock_nodeconf import ( context "context" diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index 0e2a31ed..dae887e6 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package list -destination list_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list ACLList +//go:generate mockgen -destination mock_list/mock_list.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list ACLList package list import ( diff --git a/pkg/acl/list/list_mock.go b/pkg/acl/list/mock_list/mock_list.go similarity index 90% rename from pkg/acl/list/list_mock.go rename to pkg/acl/list/mock_list/mock_list.go index 215ca59e..e4c7cc6e 100644 --- a/pkg/acl/list/list_mock.go +++ b/pkg/acl/list/mock_list/mock_list.go @@ -1,13 +1,14 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list (interfaces: ACLList) -// Package list is a generated GoMock package. -package list +// Package mock_list is a generated GoMock package. +package mock_list import ( reflect "reflect" aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + list "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" gomock "github.com/golang/mock/gomock" ) @@ -35,10 +36,10 @@ func (m *MockACLList) EXPECT() *MockACLListMockRecorder { } // ACLState mocks base method. -func (m *MockACLList) ACLState() *ACLState { +func (m *MockACLList) ACLState() *list.ACLState { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ACLState") - ret0, _ := ret[0].(*ACLState) + ret0, _ := ret[0].(*list.ACLState) return ret0 } @@ -63,10 +64,10 @@ func (mr *MockACLListMockRecorder) Close() *gomock.Call { } // Get mocks base method. -func (m *MockACLList) Get(arg0 string) (*ACLRecord, error) { +func (m *MockACLList) Get(arg0 string) (*list.ACLRecord, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", arg0) - ret0, _ := ret[0].(*ACLRecord) + ret0, _ := ret[0].(*list.ACLRecord) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -78,10 +79,10 @@ func (mr *MockACLListMockRecorder) Get(arg0 interface{}) *gomock.Call { } // Head mocks base method. -func (m *MockACLList) Head() *ACLRecord { +func (m *MockACLList) Head() *list.ACLRecord { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Head") - ret0, _ := ret[0].(*ACLRecord) + ret0, _ := ret[0].(*list.ACLRecord) return ret0 } @@ -121,7 +122,7 @@ func (mr *MockACLListMockRecorder) IsAfter(arg0, arg1 interface{}) *gomock.Call } // Iterate mocks base method. -func (m *MockACLList) Iterate(arg0 func(*ACLRecord) bool) { +func (m *MockACLList) Iterate(arg0 func(*list.ACLRecord) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "Iterate", arg0) } @@ -133,7 +134,7 @@ func (mr *MockACLListMockRecorder) Iterate(arg0 interface{}) *gomock.Call { } // IterateFrom mocks base method. -func (m *MockACLList) IterateFrom(arg0 string, arg1 func(*ACLRecord) bool) { +func (m *MockACLList) IterateFrom(arg0 string, arg1 func(*list.ACLRecord) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateFrom", arg0, arg1) } @@ -181,10 +182,10 @@ func (mr *MockACLListMockRecorder) RUnlock() *gomock.Call { } // Records mocks base method. -func (m *MockACLList) Records() []*ACLRecord { +func (m *MockACLList) Records() []*list.ACLRecord { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Records") - ret0, _ := ret[0].([]*ACLRecord) + ret0, _ := ret[0].([]*list.ACLRecord) return ret0 } diff --git a/pkg/acl/storage/liststorage.go b/pkg/acl/storage/liststorage.go index 19b4dfe1..7aad8a01 100644 --- a/pkg/acl/storage/liststorage.go +++ b/pkg/acl/storage/liststorage.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package storage -destination liststorage_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage ListStorage +//go:generate mockgen -destination mock_storage/mock_storage.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage ListStorage package storage import ( diff --git a/pkg/acl/storage/liststorage_mock.go b/pkg/acl/storage/mock_storage/mock_storage.go similarity index 97% rename from pkg/acl/storage/liststorage_mock.go rename to pkg/acl/storage/mock_storage/mock_storage.go index 07a5ef80..72dc884d 100644 --- a/pkg/acl/storage/liststorage_mock.go +++ b/pkg/acl/storage/mock_storage/mock_storage.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage (interfaces: ListStorage) -// Package storage is a generated GoMock package. -package storage +// Package mock_storage is a generated GoMock package. +package mock_storage import ( context "context" diff --git a/pkg/acl/tree/objecttree_mock.go b/pkg/acl/tree/mock_objecttree/mock_objecttree.go similarity index 93% rename from pkg/acl/tree/objecttree_mock.go rename to pkg/acl/tree/mock_objecttree/mock_objecttree.go index 5632850d..a4eac719 100644 --- a/pkg/acl/tree/objecttree_mock.go +++ b/pkg/acl/tree/mock_objecttree/mock_objecttree.go @@ -1,14 +1,15 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree (interfaces: ObjectTree) -// Package tree is a generated GoMock package. -package tree +// Package mock_tree is a generated GoMock package. +package mock_tree import ( context "context" reflect "reflect" storage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + tree "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" gomock "github.com/golang/mock/gomock" ) @@ -37,10 +38,10 @@ func (m *MockObjectTree) EXPECT() *MockObjectTreeMockRecorder { } // AddContent mocks base method. -func (m *MockObjectTree) AddContent(arg0 context.Context, arg1 SignableChangeContent) (AddResult, error) { +func (m *MockObjectTree) AddContent(arg0 context.Context, arg1 tree.SignableChangeContent) (tree.AddResult, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AddContent", arg0, arg1) - ret0, _ := ret[0].(AddResult) + ret0, _ := ret[0].(tree.AddResult) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -52,14 +53,14 @@ func (mr *MockObjectTreeMockRecorder) AddContent(arg0, arg1 interface{}) *gomock } // AddRawChanges mocks base method. -func (m *MockObjectTree) AddRawChanges(arg0 context.Context, arg1 ...*treechangeproto.RawTreeChangeWithId) (AddResult, error) { +func (m *MockObjectTree) AddRawChanges(arg0 context.Context, arg1 ...*treechangeproto.RawTreeChangeWithId) (tree.AddResult, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0} for _, a := range arg1 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "AddRawChanges", varargs...) - ret0, _ := ret[0].(AddResult) + ret0, _ := ret[0].(tree.AddResult) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -172,7 +173,7 @@ func (mr *MockObjectTreeMockRecorder) ID() *gomock.Call { } // Iterate mocks base method. -func (m *MockObjectTree) Iterate(arg0 func([]byte) (interface{}, error), arg1 func(*Change) bool) error { +func (m *MockObjectTree) Iterate(arg0 func([]byte) (interface{}, error), arg1 func(*tree.Change) bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Iterate", arg0, arg1) ret0, _ := ret[0].(error) @@ -186,7 +187,7 @@ func (mr *MockObjectTreeMockRecorder) Iterate(arg0, arg1 interface{}) *gomock.Ca } // IterateFrom mocks base method. -func (m *MockObjectTree) IterateFrom(arg0 string, arg1 func([]byte) (interface{}, error), arg2 func(*Change) bool) error { +func (m *MockObjectTree) IterateFrom(arg0 string, arg1 func([]byte) (interface{}, error), arg2 func(*tree.Change) bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IterateFrom", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -236,10 +237,10 @@ func (mr *MockObjectTreeMockRecorder) RUnlock() *gomock.Call { } // Root mocks base method. -func (m *MockObjectTree) Root() *Change { +func (m *MockObjectTree) Root() *tree.Change { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Root") - ret0, _ := ret[0].(*Change) + ret0, _ := ret[0].(*tree.Change) return ret0 } diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 95348feb..47305d23 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package tree -destination objecttree_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree ObjectTree +//go:generate mockgen -destination mock_objecttree/mock_objecttree.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree ObjectTree package tree import ( diff --git a/pkg/ldiff/diff.go b/pkg/ldiff/diff.go index 10346e45..2f9a5161 100644 --- a/pkg/ldiff/diff.go +++ b/pkg/ldiff/diff.go @@ -1,4 +1,4 @@ -//go:generate mockgen -package ldiff -destination diff_mock.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff Diff,Remote +//go:generate mockgen -destination mock_ldiff/mock_ldiff.go github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff Diff,Remote // Package ldiff provides a container of elements with fixed id and changeable content. // Diff can calculate the difference with another diff container (you can make it remote) with minimum hops and traffic. package ldiff diff --git a/pkg/ldiff/diff_mock.go b/pkg/ldiff/mock_ldiff/mock_ldiff.go similarity index 85% rename from pkg/ldiff/diff_mock.go rename to pkg/ldiff/mock_ldiff/mock_ldiff.go index e750af44..183e7bef 100644 --- a/pkg/ldiff/diff_mock.go +++ b/pkg/ldiff/mock_ldiff/mock_ldiff.go @@ -1,13 +1,14 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff (interfaces: Diff,Remote) -// Package ldiff is a generated GoMock package. -package ldiff +// Package mock_ldiff is a generated GoMock package. +package mock_ldiff import ( context "context" reflect "reflect" + ldiff "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" gomock "github.com/golang/mock/gomock" ) @@ -35,7 +36,7 @@ func (m *MockDiff) EXPECT() *MockDiffMockRecorder { } // Diff mocks base method. -func (m *MockDiff) Diff(arg0 context.Context, arg1 Remote) ([]string, []string, []string, error) { +func (m *MockDiff) Diff(arg0 context.Context, arg1 ldiff.Remote) ([]string, []string, []string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Diff", arg0, arg1) ret0, _ := ret[0].([]string) @@ -52,10 +53,10 @@ func (mr *MockDiffMockRecorder) Diff(arg0, arg1 interface{}) *gomock.Call { } // Ranges mocks base method. -func (m *MockDiff) Ranges(arg0 context.Context, arg1 []Range, arg2 []RangeResult) ([]RangeResult, error) { +func (m *MockDiff) Ranges(arg0 context.Context, arg1 []ldiff.Range, arg2 []ldiff.RangeResult) ([]ldiff.RangeResult, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Ranges", arg0, arg1, arg2) - ret0, _ := ret[0].([]RangeResult) + ret0, _ := ret[0].([]ldiff.RangeResult) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -81,7 +82,7 @@ func (mr *MockDiffMockRecorder) RemoveId(arg0 interface{}) *gomock.Call { } // Set mocks base method. -func (m *MockDiff) Set(arg0 ...Element) { +func (m *MockDiff) Set(arg0 ...ldiff.Element) { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -120,10 +121,10 @@ func (m *MockRemote) EXPECT() *MockRemoteMockRecorder { } // Ranges mocks base method. -func (m *MockRemote) Ranges(arg0 context.Context, arg1 []Range, arg2 []RangeResult) ([]RangeResult, error) { +func (m *MockRemote) Ranges(arg0 context.Context, arg1 []ldiff.Range, arg2 []ldiff.RangeResult) ([]ldiff.RangeResult, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Ranges", arg0, arg1, arg2) - ret0, _ := ret[0].([]RangeResult) + ret0, _ := ret[0].([]ldiff.RangeResult) ret1, _ := ret[1].(error) return ret0, ret1 }