1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00

Merge branch 'main' of github.com:anyproto/anytype-heart into feature/spaces

# Conflicts:
#	.mockery.yaml
#	core/block/collection/service.go
#	core/block/collection/service_test.go
#	core/block/editor/file/block_service_mock_test.go
#	core/block/import/mock.go
#	core/filestorage/filesync/mock_filesync/filesync_mock.go
#	core/filestorage/filesync/upload.go
#	core/subscription/service_test.go
#	pkg/lib/core/mock_core/service_mock.go
#	util/testMock/anytype_mock.go
#	util/testMock/file_service_mock.go
#	util/testMock/mockCreator/creator_mock.go
#	util/testMock/mockDetailsModifier/dm_mock.go
#	util/testMock/mockKanban/kanban_mock.go
#	util/testMock/mockRelation/relation_mock.go
#	util/testMock/mockSource/source_mock.go
#	util/testMock/mockStatus/status_mock.go
#	util/testMock/objectstore_mock.go
#	util/testMock/sbt_provider_mock.go
This commit is contained in:
Sergey 2023-10-02 17:33:02 +05:00
commit 1582a4c33c
No known key found for this signature in database
GPG key ID: 3B6BEF79160221C6
32 changed files with 1791 additions and 366 deletions

View file

@ -41,3 +41,6 @@ packages:
github.com/anyproto/anytype-heart/core/filestorage/filesync:
interfaces:
FileSync:
github.com/anyproto/anytype-heart/core/subscription:
interfaces:
CollectionService:

View file

@ -261,5 +261,5 @@ func setDefaultObjectTypeToViews(st *state.State) {
}
func isNotCreatableType(key domain.TypeKey) bool {
return lo.Contains(append(bundle.InternalTypes, bundle.TypeKeyObjectType, bundle.TypeKeySet, bundle.TypeKeyCollection), key)
return lo.Contains(append(bundle.InternalTypes, bundle.TypeKeyObjectType), key)
}

View file

@ -196,7 +196,7 @@ func TestSetObjectTypeToViews(t *testing.T) {
t.Run("object is a set by not creatable type", func(t *testing.T) {
// given
st := generateState(bundle.TypeKeySet, bundle.TypeKeyCollection.URL())
st := generateState(bundle.TypeKeySet, bundle.TypeKeyObjectType.URL())
// when
setDefaultObjectTypeToViews(st)

View file

@ -9,11 +9,12 @@
package file_test
import (
context "context"
reflect "reflect"
gomock "go.uber.org/mock/gomock"
file "github.com/anyproto/anytype-heart/core/block/editor/file"
smartblock "github.com/anyproto/anytype-heart/core/block/editor/smartblock"
process "github.com/anyproto/anytype-heart/core/block/process"
session "github.com/anyproto/anytype-heart/core/session"
pb "github.com/anyproto/anytype-heart/pb"
@ -43,9 +44,9 @@ func (m *MockBlockService) EXPECT() *MockBlockServiceMockRecorder {
}
// CreateLinkToTheNewObject mocks base method.
func (m *MockBlockService) CreateLinkToTheNewObject(arg0 context.Context, arg1 session.Context, arg2 *pb.RpcBlockLinkCreateWithObjectRequest) (string, string, error) {
func (m *MockBlockService) CreateLinkToTheNewObject(arg0 *session.Context, arg1 *pb.RpcBlockLinkCreateWithObjectRequest) (string, string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateLinkToTheNewObject", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "CreateLinkToTheNewObject", arg0, arg1)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(string)
ret2, _ := ret[2].(error)
@ -53,9 +54,37 @@ func (m *MockBlockService) CreateLinkToTheNewObject(arg0 context.Context, arg1 s
}
// CreateLinkToTheNewObject indicates an expected call of CreateLinkToTheNewObject.
func (mr *MockBlockServiceMockRecorder) CreateLinkToTheNewObject(arg0, arg1, arg2 any) *gomock.Call {
func (mr *MockBlockServiceMockRecorder) CreateLinkToTheNewObject(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLinkToTheNewObject", reflect.TypeOf((*MockBlockService)(nil).CreateLinkToTheNewObject), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLinkToTheNewObject", reflect.TypeOf((*MockBlockService)(nil).CreateLinkToTheNewObject), arg0, arg1)
}
// Do mocks base method.
func (m *MockBlockService) Do(arg0 string, arg1 func(smartblock.SmartBlock) error) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Do", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Do indicates an expected call of Do.
func (mr *MockBlockServiceMockRecorder) Do(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockBlockService)(nil).Do), arg0, arg1)
}
// DoFile mocks base method.
func (m *MockBlockService) DoFile(arg0 string, arg1 func(file.File) error) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DoFile", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// DoFile indicates an expected call of DoFile.
func (mr *MockBlockServiceMockRecorder) DoFile(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoFile", reflect.TypeOf((*MockBlockService)(nil).DoFile), arg0, arg1)
}
// ProcessAdd mocks base method.

View file

@ -9,7 +9,6 @@
package importer
import (
context "context"
reflect "reflect"
time "time"
@ -18,6 +17,7 @@ import (
gomock "go.uber.org/mock/gomock"
converter "github.com/anyproto/anytype-heart/core/block/import/converter"
session "github.com/anyproto/anytype-heart/core/session"
)
// MockCreator is a mock of Creator interface.
@ -44,9 +44,9 @@ func (m *MockCreator) EXPECT() *MockCreatorMockRecorder {
}
// Create mocks base method.
func (m *MockCreator) Create(arg0 context.Context, arg1 string, arg2 *converter.Snapshot, arg3 map[string]string, arg4 map[string]treestorage.TreeStorageCreatePayload, arg5 []string) (*types.Struct, string, error) {
func (m *MockCreator) Create(arg0 *session.Context, arg1 *converter.Snapshot, arg2 map[string]string, arg3 map[string]treestorage.TreeStorageCreatePayload, arg4 []string) (*types.Struct, string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2, arg3, arg4, arg5)
ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(*types.Struct)
ret1, _ := ret[1].(string)
ret2, _ := ret[2].(error)
@ -54,9 +54,9 @@ func (m *MockCreator) Create(arg0 context.Context, arg1 string, arg2 *converter.
}
// Create indicates an expected call of Create.
func (mr *MockCreatorMockRecorder) Create(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call {
func (mr *MockCreatorMockRecorder) Create(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockCreator)(nil).Create), arg0, arg1, arg2, arg3, arg4, arg5)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockCreator)(nil).Create), arg0, arg1, arg2, arg3, arg4)
}
// MockIDGetter is a mock of IDGetter interface.
@ -83,7 +83,7 @@ func (m *MockIDGetter) EXPECT() *MockIDGetterMockRecorder {
}
// Get mocks base method.
func (m *MockIDGetter) Get(arg0 string, arg1 *converter.Snapshot, arg2 time.Time, arg3 bool) (string, treestorage.TreeStorageCreatePayload, error) {
func (m *MockIDGetter) Get(arg0 *session.Context, arg1 *converter.Snapshot, arg2 time.Time, arg3 bool) (string, treestorage.TreeStorageCreatePayload, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(string)

View file

@ -142,9 +142,19 @@ func (s *service) fileAdd(ctx context.Context, spaceID string, opts AddOptions)
return "", nil, err
}
err = s.storeFileSize(nodeHash)
if err != nil {
return "", nil, fmt.Errorf("store file size: %w", err)
}
return nodeHash, fileInfo, nil
}
func (s *service) storeFileSize(hash string) error {
_, err := s.fileSync.CalculateFileSize(context.Background(), hash)
return err
}
// fileRestoreKeys restores file path=>key map from the IPFS DAG using the keys in the localStore
func (s *service) fileRestoreKeys(ctx context.Context, id domain.FullID) (map[string]string, error) {
dagService := s.dagServiceForSpace(id.SpaceID)

View file

@ -24,6 +24,9 @@ func (s *service) ImageByHash(ctx context.Context, id domain.FullID) (Image, err
return nil, err
}
// TODO Can we use FileByHash here? FileByHash contains important syncing logic. Yes, we use FileByHash before ImageByHash
// but it doesn't seem to be clear why we repeat file indexing process here
// check the image files count explicitly because we have a bug when the info can be cached not fully(only for some files)
if len(files) < 4 || files[0].MetaHash == "" {
// index image files info from ipfs
@ -114,5 +117,11 @@ func (s *service) imageAdd(ctx context.Context, spaceID string, opts AddOptions)
variantsByWidth[int(v.GetNumberValue())] = f
}
}
err = s.storeFileSize(nodeHash)
if err != nil {
return "", nil, fmt.Errorf("store file size: %w", err)
}
return nodeHash, variantsByWidth, nil
}

View file

@ -211,6 +211,21 @@ func (mr *MockFileStoreMockRecorder) GetFileKeys(arg0 any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFileKeys", reflect.TypeOf((*MockFileStore)(nil).GetFileKeys), arg0)
}
// GetFileSize mocks base method.
func (m *MockFileStore) GetFileSize(arg0 string) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetFileSize", arg0)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetFileSize indicates an expected call of GetFileSize.
func (mr *MockFileStoreMockRecorder) GetFileSize(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFileSize", reflect.TypeOf((*MockFileStore)(nil).GetFileSize), arg0)
}
// GetSyncStatus mocks base method.
func (m *MockFileStore) GetSyncStatus(arg0 string) (int, error) {
m.ctrl.T.Helper()
@ -370,6 +385,20 @@ func (mr *MockFileStoreMockRecorder) SetChunksCount(arg0, arg1 any) *gomock.Call
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetChunksCount", reflect.TypeOf((*MockFileStore)(nil).SetChunksCount), arg0, arg1)
}
// SetFileSize mocks base method.
func (m *MockFileStore) SetFileSize(arg0 string, arg1 int) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetFileSize", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// SetFileSize indicates an expected call of SetFileSize.
func (mr *MockFileStoreMockRecorder) SetFileSize(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFileSize", reflect.TypeOf((*MockFileStore)(nil).SetFileSize), arg0, arg1)
}
// SetIsFileImported mocks base method.
func (m *MockFileStore) SetIsFileImported(arg0 string, arg1 bool) error {
m.ctrl.T.Helper()

View file

@ -44,6 +44,7 @@ type FileSync interface {
DebugQueue(*http.Request) (*QueueInfo, error)
SendImportEvents()
ClearImportEvents()
CalculateFileSize(ctx context.Context, fileID string) (int, error)
app.ComponentRunnable
}

View file

@ -49,7 +49,8 @@ func TestFileSync_AddFile(t *testing.T) {
spaceId := "space1"
fx.fileStoreMock.EXPECT().GetSyncStatus(fileId).Return(int(syncstatus.StatusNotSynced), nil)
fx.fileStoreMock.EXPECT().GetFileSize(fileId).Return(0, fmt.Errorf("not found"))
fx.fileStoreMock.EXPECT().SetFileSize(fileId, gomock.Any()).Return(nil)
fx.fileStoreMock.EXPECT().ListByTarget(fileId).Return([]*storage.FileInfo{
{}, // We can use just empty struct here, because we don't use any fields
}, nil).AnyTimes()

View file

@ -0,0 +1,299 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/core/filestorage/filesync (interfaces: FileSync)
//
// Generated by this command:
//
// mockgen -package mock_filesync -destination ./mock_filesync/filesync_mock.go github.com/anyproto/anytype-heart/core/filestorage/filesync FileSync
//
// Package mock_filesync is a generated GoMock package.
package mock_filesync
import (
context "context"
http "net/http"
reflect "reflect"
app "github.com/anyproto/any-sync/app"
format "github.com/ipfs/go-ipld-format"
gomock "go.uber.org/mock/gomock"
filesync "github.com/anyproto/anytype-heart/core/filestorage/filesync"
)
// MockFileSync is a mock of FileSync interface.
type MockFileSync struct {
ctrl *gomock.Controller
recorder *MockFileSyncMockRecorder
}
// MockFileSyncMockRecorder is the mock recorder for MockFileSync.
type MockFileSyncMockRecorder struct {
mock *MockFileSync
}
// NewMockFileSync creates a new mock instance.
func NewMockFileSync(ctrl *gomock.Controller) *MockFileSync {
mock := &MockFileSync{ctrl: ctrl}
mock.recorder = &MockFileSyncMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockFileSync) EXPECT() *MockFileSyncMockRecorder {
return m.recorder
}
// AddFile mocks base method.
func (m *MockFileSync) AddFile(arg0, arg1 string, arg2, arg3 bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AddFile", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(error)
return ret0
}
// AddFile indicates an expected call of AddFile.
func (mr *MockFileSyncMockRecorder) AddFile(arg0, arg1, arg2, arg3 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddFile", reflect.TypeOf((*MockFileSync)(nil).AddFile), arg0, arg1, arg2, arg3)
}
// CalculateFileSize mocks base method.
func (m *MockFileSync) CalculateFileSize(arg0 context.Context, arg1 string) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CalculateFileSize", arg0, arg1)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CalculateFileSize indicates an expected call of CalculateFileSize.
func (mr *MockFileSyncMockRecorder) CalculateFileSize(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CalculateFileSize", reflect.TypeOf((*MockFileSync)(nil).CalculateFileSize), arg0, arg1)
}
// ClearImportEvents mocks base method.
func (m *MockFileSync) ClearImportEvents() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ClearImportEvents")
}
// ClearImportEvents indicates an expected call of ClearImportEvents.
func (mr *MockFileSyncMockRecorder) ClearImportEvents() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearImportEvents", reflect.TypeOf((*MockFileSync)(nil).ClearImportEvents))
}
// Close mocks base method.
func (m *MockFileSync) Close(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Close", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Close indicates an expected call of Close.
func (mr *MockFileSyncMockRecorder) Close(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockFileSync)(nil).Close), arg0)
}
// DebugQueue mocks base method.
func (m *MockFileSync) DebugQueue(arg0 *http.Request) (*filesync.QueueInfo, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DebugQueue", arg0)
ret0, _ := ret[0].(*filesync.QueueInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DebugQueue indicates an expected call of DebugQueue.
func (mr *MockFileSyncMockRecorder) DebugQueue(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DebugQueue", reflect.TypeOf((*MockFileSync)(nil).DebugQueue), arg0)
}
// FetchChunksCount mocks base method.
func (m *MockFileSync) FetchChunksCount(arg0 context.Context, arg1 format.Node) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchChunksCount", arg0, arg1)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FetchChunksCount indicates an expected call of FetchChunksCount.
func (mr *MockFileSyncMockRecorder) FetchChunksCount(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchChunksCount", reflect.TypeOf((*MockFileSync)(nil).FetchChunksCount), arg0, arg1)
}
// FileListStats mocks base method.
func (m *MockFileSync) FileListStats(arg0 context.Context, arg1 string, arg2 []string) ([]filesync.FileStat, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FileListStats", arg0, arg1, arg2)
ret0, _ := ret[0].([]filesync.FileStat)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FileListStats indicates an expected call of FileListStats.
func (mr *MockFileSyncMockRecorder) FileListStats(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileListStats", reflect.TypeOf((*MockFileSync)(nil).FileListStats), arg0, arg1, arg2)
}
// FileStat mocks base method.
func (m *MockFileSync) FileStat(arg0 context.Context, arg1, arg2 string) (filesync.FileStat, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FileStat", arg0, arg1, arg2)
ret0, _ := ret[0].(filesync.FileStat)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FileStat indicates an expected call of FileStat.
func (mr *MockFileSyncMockRecorder) FileStat(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileStat", reflect.TypeOf((*MockFileSync)(nil).FileStat), arg0, arg1, arg2)
}
// HasUpload mocks base method.
func (m *MockFileSync) HasUpload(arg0, arg1 string) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HasUpload", arg0, arg1)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// HasUpload indicates an expected call of HasUpload.
func (mr *MockFileSyncMockRecorder) HasUpload(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUpload", reflect.TypeOf((*MockFileSync)(nil).HasUpload), arg0, arg1)
}
// Init mocks base method.
func (m *MockFileSync) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Init", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Init indicates an expected call of Init.
func (mr *MockFileSyncMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockFileSync)(nil).Init), arg0)
}
// IsFileUploadLimited mocks base method.
func (m *MockFileSync) IsFileUploadLimited(arg0, arg1 string) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsFileUploadLimited", arg0, arg1)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// IsFileUploadLimited indicates an expected call of IsFileUploadLimited.
func (mr *MockFileSyncMockRecorder) IsFileUploadLimited(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsFileUploadLimited", reflect.TypeOf((*MockFileSync)(nil).IsFileUploadLimited), arg0, arg1)
}
// Name mocks base method.
func (m *MockFileSync) Name() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Name")
ret0, _ := ret[0].(string)
return ret0
}
// Name indicates an expected call of Name.
func (mr *MockFileSyncMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockFileSync)(nil).Name))
}
// OnUpload mocks base method.
func (m *MockFileSync) OnUpload(arg0 func(string, string) error) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "OnUpload", arg0)
}
// OnUpload indicates an expected call of OnUpload.
func (mr *MockFileSyncMockRecorder) OnUpload(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnUpload", reflect.TypeOf((*MockFileSync)(nil).OnUpload), arg0)
}
// RemoveFile mocks base method.
func (m *MockFileSync) RemoveFile(arg0, arg1 string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RemoveFile", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// RemoveFile indicates an expected call of RemoveFile.
func (mr *MockFileSyncMockRecorder) RemoveFile(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveFile", reflect.TypeOf((*MockFileSync)(nil).RemoveFile), arg0, arg1)
}
// Run mocks base method.
func (m *MockFileSync) Run(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Run", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Run indicates an expected call of Run.
func (mr *MockFileSyncMockRecorder) Run(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockFileSync)(nil).Run), arg0)
}
// SendImportEvents mocks base method.
func (m *MockFileSync) SendImportEvents() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SendImportEvents")
}
// SendImportEvents indicates an expected call of SendImportEvents.
func (mr *MockFileSyncMockRecorder) SendImportEvents() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendImportEvents", reflect.TypeOf((*MockFileSync)(nil).SendImportEvents))
}
// SpaceStat mocks base method.
func (m *MockFileSync) SpaceStat(arg0 context.Context, arg1 string) (filesync.SpaceStat, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SpaceStat", arg0, arg1)
ret0, _ := ret[0].(filesync.SpaceStat)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SpaceStat indicates an expected call of SpaceStat.
func (mr *MockFileSyncMockRecorder) SpaceStat(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceStat", reflect.TypeOf((*MockFileSync)(nil).SpaceStat), arg0, arg1)
}
// SyncStatus mocks base method.
func (m *MockFileSync) SyncStatus() (filesync.SyncStatus, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SyncStatus")
ret0, _ := ret[0].(filesync.SyncStatus)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SyncStatus indicates an expected call of SyncStatus.
func (mr *MockFileSyncMockRecorder) SyncStatus() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncStatus", reflect.TypeOf((*MockFileSync)(nil).SyncStatus))
}

View file

@ -4,15 +4,12 @@ import (
"context"
"errors"
"fmt"
"math"
"strings"
"time"
"github.com/anyproto/any-sync/commonfile/fileproto"
"github.com/anyproto/any-sync/commonfile/fileproto/fileprotoerr"
"github.com/anyproto/any-sync/commonfile/fileservice"
"github.com/anyproto/any-sync/commonspace/syncstatus"
"github.com/cheggaaa/mb/v3"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
@ -132,7 +129,6 @@ func (f *fileSync) tryToUpload() (string, error) {
}
return fileId, err
}
log.Warn("done upload", zap.String("fileID", fileId))
if f.onUpload != nil {
err := f.onUpload(spaceId, fileId)
if err != nil {
@ -155,142 +151,42 @@ func isLimitReachedErr(err error) bool {
return errors.Is(err, errReachedLimit) || strings.Contains(err.Error(), fileprotoerr.ErrSpaceLimitExceeded.Error())
}
func (f *fileSync) uploadFile(ctx context.Context, spaceId, fileId string) (err error) {
log.Debug("uploading file", zap.String("fileId", fileId))
func (f *fileSync) uploadFile(ctx context.Context, spaceID string, fileID string) error {
log.Debug("uploading file", zap.String("fileID", fileID))
var (
batcher = mb.New[blocks.Block](10)
dagErr = make(chan error, 1)
bs []blocks.Block
)
defer func() {
_ = batcher.Close()
}()
blocksToUpload, err := f.prepareToUpload(ctx, spaceId, fileId)
fileSize, err := f.CalculateFileSize(ctx, fileID)
if err != nil {
return err
return fmt.Errorf("calculate file size: %w", err)
}
stat, err := f.getAndUpdateSpaceStat(ctx, spaceID)
if err != nil {
return fmt.Errorf("get space stat: %w", err)
}
if len(blocksToUpload) == 0 {
return nil
bytesLeft := stat.BytesLimit - stat.BytesUsage
if fileSize > bytesLeft {
return errReachedLimit
}
log.Info("start uploading file", zap.String("fileID", fileId), zap.Int("blocksCount", len(blocksToUpload)))
go func() {
defer func() {
_ = batcher.Close()
}()
proc := func() error {
for _, b := range blocksToUpload {
if addErr := batcher.Add(ctx, b); addErr != nil {
return addErr
}
}
return nil
var totalBytesUploaded int
err = f.walkFileBlocks(ctx, fileID, func(fileBlocks []blocks.Block) error {
bytesToUpload, blocksToUpload, err := f.selectBlocksToUploadAndBindExisting(ctx, spaceID, fileID, fileBlocks)
if err != nil {
return fmt.Errorf("select blocks to upload: %w", err)
}
dagErr <- proc()
}()
for {
if bs, err = batcher.Wait(ctx); err != nil {
if err == mb.ErrClosed {
err = nil
break
} else {
return err
}
}
if err = f.rpcStore.AddToFile(ctx, spaceId, fileId, bs); err != nil {
if err = f.rpcStore.AddToFile(ctx, spaceID, fileID, blocksToUpload); err != nil {
return err
}
}
return <-dagErr
}
func (f *fileSync) prepareToUpload(ctx context.Context, spaceId string, fileId string) ([]blocks.Block, error) {
estimatedSize, err := f.estimateFileSize(fileId)
totalBytesUploaded += bytesToUpload
return nil
})
if err != nil {
return nil, fmt.Errorf("estimate file size: %w", err)
}
stat, err := f.getAndUpdateSpaceStat(ctx, spaceId)
if err != nil {
return nil, fmt.Errorf("get space stat: %w", err)
}
vacantSpace := stat.BytesLimit - stat.BytesUsage
if estimatedSize > vacantSpace {
return nil, errReachedLimit
return fmt.Errorf("walk file blocks: %w", err)
}
fileBlocks, err := f.collectFileBlocks(ctx, spaceId, fileId)
if err != nil {
return nil, fmt.Errorf("collect file blocks: %w", err)
}
log.Warn("done upload", zap.String("fileID", fileID), zap.Int("estimatedSize", fileSize), zap.Int("bytesUploaded", totalBytesUploaded))
bytesToUpload, blocksToUpload, err := f.selectBlocksToUploadAndBindExisting(ctx, spaceId, fileId, fileBlocks)
if err != nil {
return nil, fmt.Errorf("select blocks to upload: %w", err)
}
if len(blocksToUpload) > 0 {
log.Warn("collecting blocks to upload",
zap.String("fileID", fileId),
zap.Int("blocksToUpload", len(blocksToUpload)),
zap.Int("totalBlocks", len(fileBlocks)),
)
}
if len(blocksToUpload) > 0 && bytesToUpload > vacantSpace {
return nil, errReachedLimit
}
return blocksToUpload, nil
}
// estimateFileSize use heuristic to estimate file size. It's pretty accurate for ordinary files,
// But getting worse for images because they have a different structure.
// Samples of estimation errors in bytes (the bigger the file, the bigger the error):
/*
Estimation error: 968 10Mb jpeg file
Estimation error: 1401 30Mb png file
Estimation error: 810 50Mb ordinary file
Estimation error: 3576 250Mb ordinary file
*/
// Ordinary file structure:
/*
- dir (root)
- dir (content and meta pair)
- meta
- content (just content if file < 1Mb, and chunks list otherwise)
- chunk1
- chunk2
...
*/
func (f *fileSync) estimateFileSize(fileID string) (int, error) {
const (
linkSize = 50 // Roughly minimal size of a link
metaNodeSize = 300 // Roughly minimal size of a meta node
chunkSize = fileservice.ChunkSize
)
fileInfos, err := f.fileStore.ListByTarget(fileID)
if err != nil {
return 0, fmt.Errorf("list file info: %w", err)
}
var totalSize int
for _, info := range fileInfos {
// Content is divided by chunks of 1Mb, and chunk is linked to the directory node
chunksCount := math.Ceil(float64(info.Size_) / float64(chunkSize))
totalSize += int(info.Size_) + int(chunksCount)*linkSize
totalSize += metaNodeSize + linkSize
}
totalSize += linkSize // for root node
return totalSize, nil
return nil
}
func (f *fileSync) hasFileInStore(fileID string) (bool, error) {
@ -376,30 +272,86 @@ func (f *fileSync) selectBlocksToUploadAndBindExisting(ctx context.Context, spac
return bytesToUpload, blocksToUpload, nil
}
func (f *fileSync) collectFileBlocks(ctx context.Context, spaceID string, fileID string) (result []blocks.Block, err error) {
func (f *fileSync) walkDAG(ctx context.Context, fileID string, visit func(node ipld.Node) error) error {
fileCid, err := cid.Parse(fileID)
if err != nil {
return
return fmt.Errorf("parse CID %s: %w", fileID, err)
}
dagService := f.dagServiceForSpace(spaceID)
node, err := dagService.Get(ctx, fileCid)
rootNode, err := dagService.Get(ctx, fileCid)
if err != nil {
return
return fmt.Errorf("get root node: %w", err)
}
walker := ipld.NewWalker(ctx, ipld.NewNavigableIPLDNode(node, dagService))
err = walker.Iterate(func(node ipld.NavigableNode) error {
b, err := blocks.NewBlockWithCid(node.GetIPLDNode().RawData(), node.GetIPLDNode().Cid())
visited := map[cid.Cid]struct{}{}
walker := ipld.NewWalker(ctx, ipld.NewNavigableIPLDNode(rootNode, dagService))
err = walker.Iterate(func(navNode ipld.NavigableNode) error {
node := navNode.GetIPLDNode()
if _, ok := visited[node.Cid()]; !ok {
visited[node.Cid()] = struct{}{}
return visit(node)
}
return nil
})
if errors.Is(err, ipld.EndOfDag) {
err = nil
}
return err
}
// CalculateFileSize calculates or gets already calculated file size
func (f *fileSync) CalculateFileSize(ctx context.Context, fileID string) (int, error) {
size, err := f.fileStore.GetFileSize(fileID)
if err == nil {
return size, nil
}
size = 0
err = f.walkDAG(ctx, fileID, func(node ipld.Node) error {
size += len(node.RawData())
return nil
})
if err != nil {
return 0, fmt.Errorf("walk DAG: %w", err)
}
err = f.fileStore.SetFileSize(fileID, size)
if err != nil {
log.Error("can't store file size", zap.String("fileID", fileID), zap.Error(err))
}
return size, nil
}
const batchSize = 10
func (f *fileSync) walkFileBlocks(ctx context.Context, fileID string, proc func(fileBlocks []blocks.Block) error) error {
blocksBuf := make([]blocks.Block, 0, batchSize)
err := f.walkDAG(ctx, fileID, func(node ipld.Node) error {
b, err := blocks.NewBlockWithCid(node.RawData(), node.Cid())
if err != nil {
return err
}
result = append(result, b)
blocksBuf = append(blocksBuf, b)
if len(blocksBuf) == batchSize {
err = proc(blocksBuf)
if err != nil {
return fmt.Errorf("process batch: %w", err)
}
blocksBuf = blocksBuf[:0]
}
return nil
})
if err == ipld.EndOfDag {
err = nil
if err != nil {
return fmt.Errorf("walk DAG: %w", err)
}
return
if len(blocksBuf) > 0 {
err = proc(blocksBuf)
if err != nil {
return fmt.Errorf("process batch: %w", err)
}
}
return nil
}
func (f *fileSync) HasUpload(spaceId, fileId string) (ok bool, err error) {

View file

@ -0,0 +1,130 @@
// Code generated by mockery v2.30.1. DO NOT EDIT.
package mock_subscription
import mock "github.com/stretchr/testify/mock"
// MockCollectionService is an autogenerated mock type for the CollectionService type
type MockCollectionService struct {
mock.Mock
}
type MockCollectionService_Expecter struct {
mock *mock.Mock
}
func (_m *MockCollectionService) EXPECT() *MockCollectionService_Expecter {
return &MockCollectionService_Expecter{mock: &_m.Mock}
}
// SubscribeForCollection provides a mock function with given fields: collectionID, subscriptionID
func (_m *MockCollectionService) SubscribeForCollection(collectionID string, subscriptionID string) ([]string, <-chan []string, error) {
ret := _m.Called(collectionID, subscriptionID)
var r0 []string
var r1 <-chan []string
var r2 error
if rf, ok := ret.Get(0).(func(string, string) ([]string, <-chan []string, error)); ok {
return rf(collectionID, subscriptionID)
}
if rf, ok := ret.Get(0).(func(string, string) []string); ok {
r0 = rf(collectionID, subscriptionID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]string)
}
}
if rf, ok := ret.Get(1).(func(string, string) <-chan []string); ok {
r1 = rf(collectionID, subscriptionID)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(<-chan []string)
}
}
if rf, ok := ret.Get(2).(func(string, string) error); ok {
r2 = rf(collectionID, subscriptionID)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// MockCollectionService_SubscribeForCollection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribeForCollection'
type MockCollectionService_SubscribeForCollection_Call struct {
*mock.Call
}
// SubscribeForCollection is a helper method to define mock.On call
// - collectionID string
// - subscriptionID string
func (_e *MockCollectionService_Expecter) SubscribeForCollection(collectionID interface{}, subscriptionID interface{}) *MockCollectionService_SubscribeForCollection_Call {
return &MockCollectionService_SubscribeForCollection_Call{Call: _e.mock.On("SubscribeForCollection", collectionID, subscriptionID)}
}
func (_c *MockCollectionService_SubscribeForCollection_Call) Run(run func(collectionID string, subscriptionID string)) *MockCollectionService_SubscribeForCollection_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(string), args[1].(string))
})
return _c
}
func (_c *MockCollectionService_SubscribeForCollection_Call) Return(_a0 []string, _a1 <-chan []string, _a2 error) *MockCollectionService_SubscribeForCollection_Call {
_c.Call.Return(_a0, _a1, _a2)
return _c
}
func (_c *MockCollectionService_SubscribeForCollection_Call) RunAndReturn(run func(string, string) ([]string, <-chan []string, error)) *MockCollectionService_SubscribeForCollection_Call {
_c.Call.Return(run)
return _c
}
// UnsubscribeFromCollection provides a mock function with given fields: collectionID, subscriptionID
func (_m *MockCollectionService) UnsubscribeFromCollection(collectionID string, subscriptionID string) {
_m.Called(collectionID, subscriptionID)
}
// MockCollectionService_UnsubscribeFromCollection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UnsubscribeFromCollection'
type MockCollectionService_UnsubscribeFromCollection_Call struct {
*mock.Call
}
// UnsubscribeFromCollection is a helper method to define mock.On call
// - collectionID string
// - subscriptionID string
func (_e *MockCollectionService_Expecter) UnsubscribeFromCollection(collectionID interface{}, subscriptionID interface{}) *MockCollectionService_UnsubscribeFromCollection_Call {
return &MockCollectionService_UnsubscribeFromCollection_Call{Call: _e.mock.On("UnsubscribeFromCollection", collectionID, subscriptionID)}
}
func (_c *MockCollectionService_UnsubscribeFromCollection_Call) Run(run func(collectionID string, subscriptionID string)) *MockCollectionService_UnsubscribeFromCollection_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(string), args[1].(string))
})
return _c
}
func (_c *MockCollectionService_UnsubscribeFromCollection_Call) Return() *MockCollectionService_UnsubscribeFromCollection_Call {
_c.Call.Return()
return _c
}
func (_c *MockCollectionService_UnsubscribeFromCollection_Call) RunAndReturn(run func(string, string)) *MockCollectionService_UnsubscribeFromCollection_Call {
_c.Call.Return(run)
return _c
}
// NewMockCollectionService creates a new instance of MockCollectionService. 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 NewMockCollectionService(t interface {
mock.TestingT
Cleanup(func())
}) *MockCollectionService {
mock := &MockCollectionService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}

View file

@ -274,7 +274,7 @@ func (s *service) subscribeForCollection(req pb.RpcObjectSearchSubscribeRequest,
var depRecords, subRecords []*types.Struct
subRecords = sub.getActiveRecords()
if sub.sortedSub.depSub != nil {
if sub.sortedSub.depSub != nil && !sub.sortedSub.disableDep {
depRecords = sub.sortedSub.depSub.getActiveRecords()
}

View file

@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"testing"
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
@ -299,6 +300,354 @@ func TestService_Search(t *testing.T) {
assert.NotEmpty(t, fx.events[0].Messages[3].GetSubscriptionCounters())
assert.NotEmpty(t, fx.events[0].Messages[0].GetObjectDetailsSet().Details)
})
t.Run("collection: error getting collections entries - no records in response", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return(nil, nil, fmt.Errorf("error"))
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: "subId",
CollectionId: collectionID,
})
require.Error(t, err)
assert.Nil(t, resp)
})
t.Run("collection: collection is empty - no records in response", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return(nil, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
CollectionId: collectionID,
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 0)
assert.Len(t, resp.Dependencies, 0)
})
t.Run("collection: collection has 2 objects - return 2 objects in response", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return([]string{"1", "2"}, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
fx.store.EXPECT().QueryByID([]string{"1", "2"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("1"),
"name": pbtypes.String("1"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("2"),
"name": pbtypes.String("2"),
}}},
}, nil)
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyName.String()).Return(&model.Relation{
Key: bundle.RelationKeyName.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyId.String()).Return(&model.Relation{
Key: bundle.RelationKeyId.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
Keys: []string{bundle.RelationKeyName.String(), bundle.RelationKeyId.String()},
CollectionId: collectionID,
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 2)
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyName.String()))
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyId.String()))
assert.Equal(t, "2", pbtypes.GetString(resp.Records[1], bundle.RelationKeyName.String()))
assert.Equal(t, "2", pbtypes.GetString(resp.Records[1], bundle.RelationKeyId.String()))
})
t.Run("collection: collection has 3 objects, 1 is filtered - return 2 objects in response", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return([]string{"1", "2", "3"}, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
fx.store.EXPECT().QueryByID([]string{"1", "2", "3"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("1"),
"name": pbtypes.String("1"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("2"),
"name": pbtypes.String("2"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("3"),
"name": pbtypes.String("3"),
}}},
}, nil)
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyName.String()).Return(&model.Relation{
Key: bundle.RelationKeyName.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyId.String()).Return(&model.Relation{
Key: bundle.RelationKeyId.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
Keys: []string{bundle.RelationKeyName.String(), bundle.RelationKeyId.String()},
CollectionId: collectionID,
Filters: []*model.BlockContentDataviewFilter{
{
Id: "1",
RelationKey: bundle.RelationKeyName.String(),
Condition: model.BlockContentDataviewFilter_NotEqual,
Value: pbtypes.String("3"),
},
},
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 2)
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyName.String()))
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyId.String()))
assert.Equal(t, "2", pbtypes.GetString(resp.Records[1], bundle.RelationKeyName.String()))
assert.Equal(t, "2", pbtypes.GetString(resp.Records[1], bundle.RelationKeyId.String()))
})
t.Run("collection: collection has 3 objects, offset = 2 - return 1 object after offset", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return([]string{"1", "2", "3"}, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
fx.store.EXPECT().QueryByID([]string{"1", "2", "3"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("1"),
"name": pbtypes.String("1"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("2"),
"name": pbtypes.String("2"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("3"),
"name": pbtypes.String("3"),
}}},
}, nil)
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyName.String()).Return(&model.Relation{
Key: bundle.RelationKeyName.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyId.String()).Return(&model.Relation{
Key: bundle.RelationKeyId.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
Keys: []string{bundle.RelationKeyName.String(), bundle.RelationKeyId.String()},
CollectionId: collectionID,
Offset: 2,
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 1)
assert.Equal(t, "3", pbtypes.GetString(resp.Records[0], bundle.RelationKeyName.String()))
assert.Equal(t, "3", pbtypes.GetString(resp.Records[0], bundle.RelationKeyId.String()))
})
t.Run("collection: collection has object with dependency - return objects without dependency", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
testRelationKey := "link_to_object"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return([]string{"1"}, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
fx.store.EXPECT().QueryByID([]string{"1"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("1"),
"name": pbtypes.String("1"),
testRelationKey: pbtypes.String("2"),
}}},
}, nil)
// dependency
fx.store.EXPECT().QueryByID([]string{"2"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("2"),
"name": pbtypes.String("2"),
}}},
}, nil)
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyName.String()).Return(&model.Relation{
Key: bundle.RelationKeyName.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
fx.store.EXPECT().GetRelationByKey(testRelationKey).Return(&model.Relation{
Key: testRelationKey,
Format: model.RelationFormat_object,
}, nil).AnyTimes()
s := fx.Service.(*service)
s.ds = newDependencyService(s)
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
Keys: []string{bundle.RelationKeyName.String(), bundle.RelationKeyId.String(), testRelationKey},
CollectionId: collectionID,
NoDepSubscription: true,
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 1)
assert.Len(t, resp.Dependencies, 0)
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyName.String()))
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyId.String()))
})
t.Run("collection: collection has object with dependency - return objects with dependency", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
testRelationKey := "link_to_object"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return([]string{"1"}, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
fx.store.EXPECT().QueryByID([]string{"1"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("1"),
"name": pbtypes.String("1"),
testRelationKey: pbtypes.String("2"),
}}},
}, nil)
// dependency
fx.store.EXPECT().QueryByID([]string{"2"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("2"),
"name": pbtypes.String("2"),
}}},
}, nil)
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyName.String()).Return(&model.Relation{
Key: bundle.RelationKeyName.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
fx.store.EXPECT().GetRelationByKey(testRelationKey).Return(&model.Relation{
Key: testRelationKey,
Format: model.RelationFormat_object,
}, nil).AnyTimes()
s := fx.Service.(*service)
s.ds = newDependencyService(s)
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
Keys: []string{bundle.RelationKeyName.String(), bundle.RelationKeyId.String(), testRelationKey},
CollectionId: collectionID,
NoDepSubscription: false,
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 1)
assert.Len(t, resp.Dependencies, 1)
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyName.String()))
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyId.String()))
assert.Equal(t, "2", pbtypes.GetString(resp.Dependencies[0], bundle.RelationKeyName.String()))
assert.Equal(t, "2", pbtypes.GetString(resp.Dependencies[0], bundle.RelationKeyId.String()))
})
t.Run("collection: collection has 3 objects, but limit = 2 - return 2 objects in response", func(t *testing.T) {
fx := newFixture(t)
defer fx.a.Close(context.Background())
defer fx.ctrl.Finish()
collectionID := "id"
subscriptionID := "subId"
fx.collectionService.EXPECT().SubscribeForCollection(collectionID, subscriptionID).Return([]string{"1", "2", "3"}, nil, nil)
fx.collectionService.EXPECT().UnsubscribeFromCollection(collectionID, subscriptionID).Return()
fx.store.EXPECT().QueryByID([]string{"1", "2", "3"}).Return([]database.Record{
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("1"),
"name": pbtypes.String("1"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("2"),
"name": pbtypes.String("2"),
}}},
{Details: &types.Struct{Fields: map[string]*types.Value{
"id": pbtypes.String("3"),
"name": pbtypes.String("3"),
}}},
}, nil)
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyName.String()).Return(&model.Relation{
Key: bundle.RelationKeyName.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
fx.store.EXPECT().GetRelationByKey(bundle.RelationKeyId.String()).Return(&model.Relation{
Key: bundle.RelationKeyId.String(),
Format: model.RelationFormat_shorttext,
}, nil).AnyTimes()
var resp, err = fx.Search(pb.RpcObjectSearchSubscribeRequest{
SubId: subscriptionID,
Keys: []string{bundle.RelationKeyName.String(), bundle.RelationKeyId.String()},
CollectionId: collectionID,
Limit: 1,
})
require.NoError(t, err)
assert.NotNil(t, resp)
assert.Len(t, resp.Records, 1)
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyName.String()))
assert.Equal(t, "1", pbtypes.GetString(resp.Records[0], bundle.RelationKeyId.String()))
})
}
func TestNestedSubscription(t *testing.T) {
@ -448,3 +797,4 @@ func testCreateSubscriptionWithNestedFilter(t *testing.T) *fixtureRealStore {
})
return fx
}

2
go.mod
View file

@ -46,7 +46,7 @@ require (
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-flatfs v0.5.1
github.com/ipfs/go-ipld-format v0.5.0
github.com/ipfs/go-ipld-format v0.6.0
github.com/ipfs/go-log v1.0.5
github.com/ipfs/interface-go-ipfs-core v0.11.2
github.com/joho/godotenv v1.5.1

2
go.sum
View file

@ -640,6 +640,8 @@ github.com/ipfs/go-ipld-format v0.0.2/go.mod h1:4B6+FM2u9OJ9zCV+kSbgFAZlOrv1Hqbf
github.com/ipfs/go-ipld-format v0.2.0/go.mod h1:3l3C1uKoadTPbeNfrDi+xMInYKlx2Cvg1BuydPSdzQs=
github.com/ipfs/go-ipld-format v0.5.0 h1:WyEle9K96MSrvr47zZHKKcDxJ/vlpET6PSiQsAFO+Ds=
github.com/ipfs/go-ipld-format v0.5.0/go.mod h1:ImdZqJQaEouMjCvqCe0ORUS+uoBmf7Hf+EO/jh+nk3M=
github.com/ipfs/go-ipld-format v0.6.0 h1:VEJlA2kQ3LqFSIm5Vu6eIlSxD/Ze90xtc4Meten1F5U=
github.com/ipfs/go-ipld-format v0.6.0/go.mod h1:g4QVMTn3marU3qXchwjpKPKgJv+zF+OlaKMyhJ4LHPg=
github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk=
github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM=
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=

View file

@ -0,0 +1,214 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/pkg/lib/core (interfaces: Service)
//
// Generated by this command:
//
// mockgen -package mock_core -destination ./mock_core/service_mock.go github.com/anyproto/anytype-heart/pkg/lib/core Service
//
// Package mock_core is a generated GoMock package.
package mock_core
import (
context "context"
reflect "reflect"
app "github.com/anyproto/any-sync/app"
gomock "go.uber.org/mock/gomock"
core "github.com/anyproto/anytype-heart/pkg/lib/core"
threads "github.com/anyproto/anytype-heart/pkg/lib/threads"
)
// MockService is a mock of Service interface.
type MockService struct {
ctrl *gomock.Controller
recorder *MockServiceMockRecorder
}
// MockServiceMockRecorder is the mock recorder for MockService.
type MockServiceMockRecorder struct {
mock *MockService
}
// NewMockService creates a new mock instance.
func NewMockService(ctrl *gomock.Controller) *MockService {
mock := &MockService{ctrl: ctrl}
mock.recorder = &MockServiceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockService) EXPECT() *MockServiceMockRecorder {
return m.recorder
}
// Close mocks base method.
func (m *MockService) Close(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Close", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Close indicates an expected call of Close.
func (mr *MockServiceMockRecorder) Close(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockService)(nil).Close), arg0)
}
// EnsurePredefinedBlocks mocks base method.
func (m *MockService) EnsurePredefinedBlocks(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EnsurePredefinedBlocks", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// EnsurePredefinedBlocks indicates an expected call of EnsurePredefinedBlocks.
func (mr *MockServiceMockRecorder) EnsurePredefinedBlocks(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsurePredefinedBlocks", reflect.TypeOf((*MockService)(nil).EnsurePredefinedBlocks), arg0)
}
// GetAllWorkspaces mocks base method.
func (m *MockService) GetAllWorkspaces() ([]string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllWorkspaces")
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetAllWorkspaces indicates an expected call of GetAllWorkspaces.
func (mr *MockServiceMockRecorder) GetAllWorkspaces() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllWorkspaces", reflect.TypeOf((*MockService)(nil).GetAllWorkspaces))
}
// GetWorkspaceIdForObject mocks base method.
func (m *MockService) GetWorkspaceIdForObject(arg0 string) (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetWorkspaceIdForObject", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetWorkspaceIdForObject indicates an expected call of GetWorkspaceIdForObject.
func (mr *MockServiceMockRecorder) GetWorkspaceIdForObject(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkspaceIdForObject", reflect.TypeOf((*MockService)(nil).GetWorkspaceIdForObject), arg0)
}
// Init mocks base method.
func (m *MockService) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Init", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Init indicates an expected call of Init.
func (mr *MockServiceMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockService)(nil).Init), arg0)
}
// IsStarted mocks base method.
func (m *MockService) IsStarted() bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsStarted")
ret0, _ := ret[0].(bool)
return ret0
}
// IsStarted indicates an expected call of IsStarted.
func (mr *MockServiceMockRecorder) IsStarted() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsStarted", reflect.TypeOf((*MockService)(nil).IsStarted))
}
// LocalProfile mocks base method.
func (m *MockService) LocalProfile() (core.Profile, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LocalProfile")
ret0, _ := ret[0].(core.Profile)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LocalProfile indicates an expected call of LocalProfile.
func (mr *MockServiceMockRecorder) LocalProfile() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalProfile", reflect.TypeOf((*MockService)(nil).LocalProfile))
}
// Name mocks base method.
func (m *MockService) Name() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Name")
ret0, _ := ret[0].(string)
return ret0
}
// Name indicates an expected call of Name.
func (mr *MockServiceMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockService)(nil).Name))
}
// PredefinedBlocks mocks base method.
func (m *MockService) PredefinedBlocks() threads.DerivedSmartblockIds {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PredefinedBlocks")
ret0, _ := ret[0].(threads.DerivedSmartblockIds)
return ret0
}
// PredefinedBlocks indicates an expected call of PredefinedBlocks.
func (mr *MockServiceMockRecorder) PredefinedBlocks() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PredefinedBlocks", reflect.TypeOf((*MockService)(nil).PredefinedBlocks))
}
// ProfileID mocks base method.
func (m *MockService) ProfileID() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ProfileID")
ret0, _ := ret[0].(string)
return ret0
}
// ProfileID indicates an expected call of ProfileID.
func (mr *MockServiceMockRecorder) ProfileID() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProfileID", reflect.TypeOf((*MockService)(nil).ProfileID))
}
// Run mocks base method.
func (m *MockService) Run(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Run", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Run indicates an expected call of Run.
func (mr *MockServiceMockRecorder) Run(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockService)(nil).Run), arg0)
}
// Stop mocks base method.
func (m *MockService) Stop() error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Stop")
ret0, _ := ret[0].(error)
return ret0
}
// Stop indicates an expected call of Stop.
func (mr *MockServiceMockRecorder) Stop() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockService)(nil).Stop))
}

View file

@ -26,6 +26,7 @@ var (
filesKeysBase = dsCtx.NewKey("/" + filesPrefix + "/keys")
chunksCountBase = dsCtx.NewKey("/" + filesPrefix + "/chunks_count")
syncStatusBase = dsCtx.NewKey("/" + filesPrefix + "/sync_status")
fileSizeBase = dsCtx.NewKey("/" + filesPrefix + "/file_size")
isImportedBase = dsCtx.NewKey("/" + filesPrefix + "/is_imported")
indexMillSourceOpts = localstore.Index{
@ -102,6 +103,8 @@ type FileStore interface {
SetSyncStatus(hash string, syncStatus int) error
IsFileImported(hash string) (bool, error)
SetIsFileImported(hash string, isImported bool) error
SetFileSize(hash string, size int) error
GetFileSize(hash string) (int, error)
}
func New() FileStore {
@ -525,6 +528,16 @@ func (m *dsFileStore) SetIsFileImported(hash string, isImported bool) error {
return m.setInt(key, raw)
}
func (m *dsFileStore) GetFileSize(hash string) (int, error) {
key := fileSizeBase.ChildString(hash)
return m.getInt(key)
}
func (m *dsFileStore) SetFileSize(hash string, status int) error {
key := fileSizeBase.ChildString(hash)
return m.setInt(key, status)
}
func (ls *dsFileStore) Close(ctx context.Context) (err error) {
return nil
}

View file

@ -15,7 +15,6 @@ import (
app "github.com/anyproto/any-sync/app"
gomock "go.uber.org/mock/gomock"
domain "github.com/anyproto/anytype-heart/core/domain"
core "github.com/anyproto/anytype-heart/pkg/lib/core"
threads "github.com/anyproto/anytype-heart/pkg/lib/threads"
)
@ -43,20 +42,6 @@ func (m *MockService) EXPECT() *MockServiceMockRecorder {
return m.recorder
}
// AccountObjects mocks base method.
func (m *MockService) AccountObjects() threads.DerivedSmartblockIds {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AccountObjects")
ret0, _ := ret[0].(threads.DerivedSmartblockIds)
return ret0
}
// AccountObjects indicates an expected call of AccountObjects.
func (mr *MockServiceMockRecorder) AccountObjects() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AccountObjects", reflect.TypeOf((*MockService)(nil).AccountObjects))
}
// Close mocks base method.
func (m *MockService) Close(arg0 context.Context) error {
m.ctrl.T.Helper()
@ -71,77 +56,48 @@ func (mr *MockServiceMockRecorder) Close(arg0 any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockService)(nil).Close), arg0)
}
// DeriveObjectId mocks base method.
func (m *MockService) DeriveObjectId(arg0 context.Context, arg1 string, arg2 domain.UniqueKey) (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeriveObjectId", arg0, arg1, arg2)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DeriveObjectId indicates an expected call of DeriveObjectId.
func (mr *MockServiceMockRecorder) DeriveObjectId(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeriveObjectId", reflect.TypeOf((*MockService)(nil).DeriveObjectId), arg0, arg1, arg2)
}
// DerivePredefinedObjects mocks base method.
func (m *MockService) DerivePredefinedObjects(arg0 context.Context, arg1 string, arg2 bool) (threads.DerivedSmartblockIds, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DerivePredefinedObjects", arg0, arg1, arg2)
ret0, _ := ret[0].(threads.DerivedSmartblockIds)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DerivePredefinedObjects indicates an expected call of DerivePredefinedObjects.
func (mr *MockServiceMockRecorder) DerivePredefinedObjects(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DerivePredefinedObjects", reflect.TypeOf((*MockService)(nil).DerivePredefinedObjects), arg0, arg1, arg2)
}
// EnsurePredefinedBlocks mocks base method.
func (m *MockService) EnsurePredefinedBlocks(arg0 context.Context, arg1 string) (threads.DerivedSmartblockIds, error) {
func (m *MockService) EnsurePredefinedBlocks(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EnsurePredefinedBlocks", arg0, arg1)
ret0, _ := ret[0].(threads.DerivedSmartblockIds)
ret1, _ := ret[1].(error)
return ret0, ret1
ret := m.ctrl.Call(m, "EnsurePredefinedBlocks", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// EnsurePredefinedBlocks indicates an expected call of EnsurePredefinedBlocks.
func (mr *MockServiceMockRecorder) EnsurePredefinedBlocks(arg0, arg1 any) *gomock.Call {
func (mr *MockServiceMockRecorder) EnsurePredefinedBlocks(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsurePredefinedBlocks", reflect.TypeOf((*MockService)(nil).EnsurePredefinedBlocks), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsurePredefinedBlocks", reflect.TypeOf((*MockService)(nil).EnsurePredefinedBlocks), arg0)
}
// GetSystemRelationID mocks base method.
func (m *MockService) GetSystemRelationID(arg0 string, arg1 domain.RelationKey) string {
// GetAllWorkspaces mocks base method.
func (m *MockService) GetAllWorkspaces() ([]string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetSystemRelationID", arg0, arg1)
ret0, _ := ret[0].(string)
return ret0
ret := m.ctrl.Call(m, "GetAllWorkspaces")
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetSystemRelationID indicates an expected call of GetSystemRelationID.
func (mr *MockServiceMockRecorder) GetSystemRelationID(arg0, arg1 any) *gomock.Call {
// GetAllWorkspaces indicates an expected call of GetAllWorkspaces.
func (mr *MockServiceMockRecorder) GetAllWorkspaces() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSystemRelationID", reflect.TypeOf((*MockService)(nil).GetSystemRelationID), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllWorkspaces", reflect.TypeOf((*MockService)(nil).GetAllWorkspaces))
}
// GetSystemTypeID mocks base method.
func (m *MockService) GetSystemTypeID(arg0 string, arg1 domain.TypeKey) string {
// GetWorkspaceIdForObject mocks base method.
func (m *MockService) GetWorkspaceIdForObject(arg0 string) (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetSystemTypeID", arg0, arg1)
ret := m.ctrl.Call(m, "GetWorkspaceIdForObject", arg0)
ret0, _ := ret[0].(string)
return ret0
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetSystemTypeID indicates an expected call of GetSystemTypeID.
func (mr *MockServiceMockRecorder) GetSystemTypeID(arg0, arg1 any) *gomock.Call {
// GetWorkspaceIdForObject indicates an expected call of GetWorkspaceIdForObject.
func (mr *MockServiceMockRecorder) GetWorkspaceIdForObject(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSystemTypeID", reflect.TypeOf((*MockService)(nil).GetSystemTypeID), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkspaceIdForObject", reflect.TypeOf((*MockService)(nil).GetWorkspaceIdForObject), arg0)
}
// Init mocks base method.
@ -173,18 +129,18 @@ func (mr *MockServiceMockRecorder) IsStarted() *gomock.Call {
}
// LocalProfile mocks base method.
func (m *MockService) LocalProfile(arg0 string) (core.Profile, error) {
func (m *MockService) LocalProfile() (core.Profile, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LocalProfile", arg0)
ret := m.ctrl.Call(m, "LocalProfile")
ret0, _ := ret[0].(core.Profile)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LocalProfile indicates an expected call of LocalProfile.
func (mr *MockServiceMockRecorder) LocalProfile(arg0 any) *gomock.Call {
func (mr *MockServiceMockRecorder) LocalProfile() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalProfile", reflect.TypeOf((*MockService)(nil).LocalProfile), arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalProfile", reflect.TypeOf((*MockService)(nil).LocalProfile))
}
// Name mocks base method.
@ -201,32 +157,32 @@ func (mr *MockServiceMockRecorder) Name() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockService)(nil).Name))
}
// PredefinedObjects mocks base method.
func (m *MockService) PredefinedObjects(arg0 string) threads.DerivedSmartblockIds {
// PredefinedBlocks mocks base method.
func (m *MockService) PredefinedBlocks() threads.DerivedSmartblockIds {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PredefinedObjects", arg0)
ret := m.ctrl.Call(m, "PredefinedBlocks")
ret0, _ := ret[0].(threads.DerivedSmartblockIds)
return ret0
}
// PredefinedObjects indicates an expected call of PredefinedObjects.
func (mr *MockServiceMockRecorder) PredefinedObjects(arg0 any) *gomock.Call {
// PredefinedBlocks indicates an expected call of PredefinedBlocks.
func (mr *MockServiceMockRecorder) PredefinedBlocks() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PredefinedObjects", reflect.TypeOf((*MockService)(nil).PredefinedObjects), arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PredefinedBlocks", reflect.TypeOf((*MockService)(nil).PredefinedBlocks))
}
// ProfileID mocks base method.
func (m *MockService) ProfileID(arg0 string) string {
func (m *MockService) ProfileID() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ProfileID", arg0)
ret := m.ctrl.Call(m, "ProfileID")
ret0, _ := ret[0].(string)
return ret0
}
// ProfileID indicates an expected call of ProfileID.
func (mr *MockServiceMockRecorder) ProfileID(arg0 any) *gomock.Call {
func (mr *MockServiceMockRecorder) ProfileID() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProfileID", reflect.TypeOf((*MockService)(nil).ProfileID), arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProfileID", reflect.TypeOf((*MockService)(nil).ProfileID))
}
// Run mocks base method.

View file

@ -17,7 +17,6 @@ import (
types "github.com/gogo/protobuf/types"
gomock "go.uber.org/mock/gomock"
domain "github.com/anyproto/anytype-heart/core/domain"
files "github.com/anyproto/anytype-heart/core/files"
pb "github.com/anyproto/anytype-heart/pb"
mill "github.com/anyproto/anytype-heart/pkg/lib/mill"
@ -48,10 +47,10 @@ func (m *MockFileService) EXPECT() *MockFileServiceMockRecorder {
}
// FileAdd mocks base method.
func (m *MockFileService) FileAdd(arg0 context.Context, arg1 string, arg2 ...files.AddOption) (files.File, error) {
func (m *MockFileService) FileAdd(arg0 context.Context, arg1 ...files.AddOption) (files.File, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "FileAdd", varargs...)
@ -61,14 +60,14 @@ func (m *MockFileService) FileAdd(arg0 context.Context, arg1 string, arg2 ...fil
}
// FileAdd indicates an expected call of FileAdd.
func (mr *MockFileServiceMockRecorder) FileAdd(arg0, arg1 any, arg2 ...any) *gomock.Call {
func (mr *MockFileServiceMockRecorder) FileAdd(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileAdd", reflect.TypeOf((*MockFileService)(nil).FileAdd), varargs...)
}
// FileByHash mocks base method.
func (m *MockFileService) FileByHash(arg0 context.Context, arg1 domain.FullID) (files.File, error) {
func (m *MockFileService) FileByHash(arg0 context.Context, arg1 string) (files.File, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FileByHash", arg0, arg1)
ret0, _ := ret[0].(files.File)
@ -83,7 +82,7 @@ func (mr *MockFileServiceMockRecorder) FileByHash(arg0, arg1 any) *gomock.Call {
}
// FileGetKeys mocks base method.
func (m *MockFileService) FileGetKeys(arg0 domain.FullID) (*files.FileKeys, error) {
func (m *MockFileService) FileGetKeys(arg0 string) (*files.FileKeys, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FileGetKeys", arg0)
ret0, _ := ret[0].(*files.FileKeys)
@ -98,9 +97,9 @@ func (mr *MockFileServiceMockRecorder) FileGetKeys(arg0 any) *gomock.Call {
}
// FileListOffload mocks base method.
func (m *MockFileService) FileListOffload(arg0 context.Context, arg1 []string, arg2 bool) (uint64, uint64, error) {
func (m *MockFileService) FileListOffload(arg0 []string, arg1 bool) (uint64, uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FileListOffload", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "FileListOffload", arg0, arg1)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(uint64)
ret2, _ := ret[2].(error)
@ -108,46 +107,46 @@ func (m *MockFileService) FileListOffload(arg0 context.Context, arg1 []string, a
}
// FileListOffload indicates an expected call of FileListOffload.
func (mr *MockFileServiceMockRecorder) FileListOffload(arg0, arg1, arg2 any) *gomock.Call {
func (mr *MockFileServiceMockRecorder) FileListOffload(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileListOffload", reflect.TypeOf((*MockFileService)(nil).FileListOffload), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileListOffload", reflect.TypeOf((*MockFileService)(nil).FileListOffload), arg0, arg1)
}
// FileOffload mocks base method.
func (m *MockFileService) FileOffload(arg0 context.Context, arg1 string, arg2 bool) (uint64, error) {
func (m *MockFileService) FileOffload(arg0 string, arg1 bool) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FileOffload", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "FileOffload", arg0, arg1)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FileOffload indicates an expected call of FileOffload.
func (mr *MockFileServiceMockRecorder) FileOffload(arg0, arg1, arg2 any) *gomock.Call {
func (mr *MockFileServiceMockRecorder) FileOffload(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileOffload", reflect.TypeOf((*MockFileService)(nil).FileOffload), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileOffload", reflect.TypeOf((*MockFileService)(nil).FileOffload), arg0, arg1)
}
// GetSpaceUsage mocks base method.
func (m *MockFileService) GetSpaceUsage(arg0 context.Context, arg1 string) (*pb.RpcFileSpaceUsageResponseUsage, error) {
func (m *MockFileService) GetSpaceUsage(arg0 context.Context) (*pb.RpcFileSpaceUsageResponseUsage, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetSpaceUsage", arg0, arg1)
ret := m.ctrl.Call(m, "GetSpaceUsage", arg0)
ret0, _ := ret[0].(*pb.RpcFileSpaceUsageResponseUsage)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetSpaceUsage indicates an expected call of GetSpaceUsage.
func (mr *MockFileServiceMockRecorder) GetSpaceUsage(arg0, arg1 any) *gomock.Call {
func (mr *MockFileServiceMockRecorder) GetSpaceUsage(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpaceUsage", reflect.TypeOf((*MockFileService)(nil).GetSpaceUsage), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpaceUsage", reflect.TypeOf((*MockFileService)(nil).GetSpaceUsage), arg0)
}
// ImageAdd mocks base method.
func (m *MockFileService) ImageAdd(arg0 context.Context, arg1 string, arg2 ...files.AddOption) (files.Image, error) {
func (m *MockFileService) ImageAdd(arg0 context.Context, arg1 ...files.AddOption) (files.Image, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "ImageAdd", varargs...)
@ -157,14 +156,14 @@ func (m *MockFileService) ImageAdd(arg0 context.Context, arg1 string, arg2 ...fi
}
// ImageAdd indicates an expected call of ImageAdd.
func (mr *MockFileServiceMockRecorder) ImageAdd(arg0, arg1 any, arg2 ...any) *gomock.Call {
func (mr *MockFileServiceMockRecorder) ImageAdd(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageAdd", reflect.TypeOf((*MockFileService)(nil).ImageAdd), varargs...)
}
// ImageByHash mocks base method.
func (m *MockFileService) ImageByHash(arg0 context.Context, arg1 domain.FullID) (files.Image, error) {
func (m *MockFileService) ImageByHash(arg0 context.Context, arg1 string) (files.Image, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImageByHash", arg0, arg1)
ret0, _ := ret[0].(files.Image)
@ -360,13 +359,12 @@ func (m *MockFile) EXPECT() *MockFileMockRecorder {
}
// Details mocks base method.
func (m *MockFile) Details(arg0 context.Context) (*types.Struct, domain.TypeKey, error) {
func (m *MockFile) Details(arg0 context.Context) (*types.Struct, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Details", arg0)
ret0, _ := ret[0].(*types.Struct)
ret1, _ := ret[1].(domain.TypeKey)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Details indicates an expected call of Details.

View file

@ -1,6 +1,10 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/util/builtintemplate (interfaces: BuiltinTemplate)
//
// Generated by this command:
//
// mockgen -package mockBuiltinTemplate -destination builtintemplate_mock.go github.com/anyproto/anytype-heart/util/builtintemplate BuiltinTemplate
//
// Package mockBuiltinTemplate is a generated GoMock package.
package mockBuiltinTemplate
@ -44,7 +48,7 @@ func (m *MockBuiltinTemplate) Close(arg0 context.Context) error {
}
// Close indicates an expected call of Close.
func (mr *MockBuiltinTemplateMockRecorder) Close(arg0 interface{}) *gomock.Call {
func (mr *MockBuiltinTemplateMockRecorder) Close(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockBuiltinTemplate)(nil).Close), arg0)
}
@ -72,7 +76,7 @@ func (m *MockBuiltinTemplate) Init(arg0 *app.App) error {
}
// Init indicates an expected call of Init.
func (mr *MockBuiltinTemplateMockRecorder) Init(arg0 interface{}) *gomock.Call {
func (mr *MockBuiltinTemplateMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockBuiltinTemplate)(nil).Init), arg0)
}
@ -100,7 +104,7 @@ func (m *MockBuiltinTemplate) Run(arg0 context.Context) error {
}
// Run indicates an expected call of Run.
func (mr *MockBuiltinTemplateMockRecorder) Run(arg0 interface{}) *gomock.Call {
func (mr *MockBuiltinTemplateMockRecorder) Run(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockBuiltinTemplate)(nil).Run), arg0)
}

View file

@ -0,0 +1,153 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/core/block/object/objectcreator (interfaces: Service)
//
// Generated by this command:
//
// mockgen -package mockCreator -destination creator_mock.go github.com/anyproto/anytype-heart/core/block/object/objectcreator Service
//
// Package mockCreator is a generated GoMock package.
package mockCreator
import (
context "context"
reflect "reflect"
app "github.com/anyproto/any-sync/app"
types "github.com/gogo/protobuf/types"
gomock "go.uber.org/mock/gomock"
state "github.com/anyproto/anytype-heart/core/block/editor/state"
pb "github.com/anyproto/anytype-heart/pb"
smartblock "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
)
// MockService is a mock of Service interface.
type MockService struct {
ctrl *gomock.Controller
recorder *MockServiceMockRecorder
}
// MockServiceMockRecorder is the mock recorder for MockService.
type MockServiceMockRecorder struct {
mock *MockService
}
// NewMockService creates a new mock instance.
func NewMockService(ctrl *gomock.Controller) *MockService {
mock := &MockService{ctrl: ctrl}
mock.recorder = &MockServiceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockService) EXPECT() *MockServiceMockRecorder {
return m.recorder
}
// CreateSet mocks base method.
func (m *MockService) CreateSet(arg0 *pb.RpcObjectCreateSetRequest) (string, *types.Struct, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateSet", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(*types.Struct)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// CreateSet indicates an expected call of CreateSet.
func (mr *MockServiceMockRecorder) CreateSet(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSet", reflect.TypeOf((*MockService)(nil).CreateSet), arg0)
}
// CreateSmartBlockFromState mocks base method.
func (m *MockService) CreateSmartBlockFromState(arg0 context.Context, arg1 smartblock.SmartBlockType, arg2 *types.Struct, arg3 *state.State) (string, *types.Struct, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateSmartBlockFromState", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(*types.Struct)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// CreateSmartBlockFromState indicates an expected call of CreateSmartBlockFromState.
func (mr *MockServiceMockRecorder) CreateSmartBlockFromState(arg0, arg1, arg2, arg3 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSmartBlockFromState", reflect.TypeOf((*MockService)(nil).CreateSmartBlockFromState), arg0, arg1, arg2, arg3)
}
// CreateSmartBlockFromTemplate mocks base method.
func (m *MockService) CreateSmartBlockFromTemplate(arg0 context.Context, arg1 smartblock.SmartBlockType, arg2 *types.Struct, arg3 string) (string, *types.Struct, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateSmartBlockFromTemplate", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(*types.Struct)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// CreateSmartBlockFromTemplate indicates an expected call of CreateSmartBlockFromTemplate.
func (mr *MockServiceMockRecorder) CreateSmartBlockFromTemplate(arg0, arg1, arg2, arg3 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSmartBlockFromTemplate", reflect.TypeOf((*MockService)(nil).CreateSmartBlockFromTemplate), arg0, arg1, arg2, arg3)
}
// CreateSubObjectInWorkspace mocks base method.
func (m *MockService) CreateSubObjectInWorkspace(arg0 *types.Struct, arg1 string) (string, *types.Struct, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateSubObjectInWorkspace", arg0, arg1)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(*types.Struct)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// CreateSubObjectInWorkspace indicates an expected call of CreateSubObjectInWorkspace.
func (mr *MockServiceMockRecorder) CreateSubObjectInWorkspace(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSubObjectInWorkspace", reflect.TypeOf((*MockService)(nil).CreateSubObjectInWorkspace), arg0, arg1)
}
// CreateSubObjectsInWorkspace mocks base method.
func (m *MockService) CreateSubObjectsInWorkspace(arg0 []*types.Struct) ([]string, []*types.Struct, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateSubObjectsInWorkspace", arg0)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].([]*types.Struct)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// CreateSubObjectsInWorkspace indicates an expected call of CreateSubObjectsInWorkspace.
func (mr *MockServiceMockRecorder) CreateSubObjectsInWorkspace(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSubObjectsInWorkspace", reflect.TypeOf((*MockService)(nil).CreateSubObjectsInWorkspace), arg0)
}
// Init mocks base method.
func (m *MockService) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Init", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Init indicates an expected call of Init.
func (mr *MockServiceMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockService)(nil).Init), arg0)
}
// Name mocks base method.
func (m *MockService) Name() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Name")
ret0, _ := ret[0].(string)
return ret0
}
// Name indicates an expected call of Name.
func (mr *MockServiceMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockService)(nil).Name))
}

View file

@ -13,8 +13,6 @@ import (
types "github.com/gogo/protobuf/types"
gomock "go.uber.org/mock/gomock"
session "github.com/anyproto/anytype-heart/core/session"
)
// MockDetailsModifier is a mock of DetailsModifier interface.
@ -41,17 +39,17 @@ func (m *MockDetailsModifier) EXPECT() *MockDetailsModifierMockRecorder {
}
// ModifyDetails mocks base method.
func (m *MockDetailsModifier) ModifyDetails(arg0 session.Context, arg1 string, arg2 func(*types.Struct) (*types.Struct, error)) error {
func (m *MockDetailsModifier) ModifyDetails(arg0 string, arg1 func(*types.Struct) (*types.Struct, error)) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ModifyDetails", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "ModifyDetails", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ModifyDetails indicates an expected call of ModifyDetails.
func (mr *MockDetailsModifierMockRecorder) ModifyDetails(arg0, arg1, arg2 any) *gomock.Call {
func (mr *MockDetailsModifierMockRecorder) ModifyDetails(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModifyDetails", reflect.TypeOf((*MockDetailsModifier)(nil).ModifyDetails), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModifyDetails", reflect.TypeOf((*MockDetailsModifier)(nil).ModifyDetails), arg0, arg1)
}
// ModifyLocalDetails mocks base method.

View file

@ -41,18 +41,18 @@ func (m *MockService) EXPECT() *MockServiceMockRecorder {
}
// Grouper mocks base method.
func (m *MockService) Grouper(arg0, arg1 string) (kanban.Grouper, error) {
func (m *MockService) Grouper(arg0 string) (kanban.Grouper, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Grouper", arg0, arg1)
ret := m.ctrl.Call(m, "Grouper", arg0)
ret0, _ := ret[0].(kanban.Grouper)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Grouper indicates an expected call of Grouper.
func (mr *MockServiceMockRecorder) Grouper(arg0, arg1 any) *gomock.Call {
func (mr *MockServiceMockRecorder) Grouper(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Grouper", reflect.TypeOf((*MockService)(nil).Grouper), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Grouper", reflect.TypeOf((*MockService)(nil).Grouper), arg0)
}
// Init mocks base method.

View file

@ -0,0 +1,159 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/core/relation (interfaces: Service)
//
// Generated by this command:
//
// mockgen -package mockRelation -destination relation_mock.go github.com/anyproto/anytype-heart/core/relation Service
//
// Package mockRelation is a generated GoMock package.
package mockRelation
import (
reflect "reflect"
app "github.com/anyproto/any-sync/app"
types "github.com/gogo/protobuf/types"
gomock "go.uber.org/mock/gomock"
relation "github.com/anyproto/anytype-heart/core/relation"
relationutils "github.com/anyproto/anytype-heart/core/relation/relationutils"
pbtypes "github.com/anyproto/anytype-heart/util/pbtypes"
)
// MockService is a mock of Service interface.
type MockService struct {
ctrl *gomock.Controller
recorder *MockServiceMockRecorder
}
// MockServiceMockRecorder is the mock recorder for MockService.
type MockServiceMockRecorder struct {
mock *MockService
}
// NewMockService creates a new mock instance.
func NewMockService(ctrl *gomock.Controller) *MockService {
mock := &MockService{ctrl: ctrl}
mock.recorder = &MockServiceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockService) EXPECT() *MockServiceMockRecorder {
return m.recorder
}
// FetchKey mocks base method.
func (m *MockService) FetchKey(arg0 string, arg1 ...relation.FetchOption) (*relationutils.Relation, error) {
m.ctrl.T.Helper()
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "FetchKey", varargs...)
ret0, _ := ret[0].(*relationutils.Relation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FetchKey indicates an expected call of FetchKey.
func (mr *MockServiceMockRecorder) FetchKey(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchKey", reflect.TypeOf((*MockService)(nil).FetchKey), varargs...)
}
// FetchKeys mocks base method.
func (m *MockService) FetchKeys(arg0 ...string) (relationutils.Relations, error) {
m.ctrl.T.Helper()
varargs := []any{}
for _, a := range arg0 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "FetchKeys", varargs...)
ret0, _ := ret[0].(relationutils.Relations)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FetchKeys indicates an expected call of FetchKeys.
func (mr *MockServiceMockRecorder) FetchKeys(arg0 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchKeys", reflect.TypeOf((*MockService)(nil).FetchKeys), arg0...)
}
// FetchLinks mocks base method.
func (m *MockService) FetchLinks(arg0 pbtypes.RelationLinks) (relationutils.Relations, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchLinks", arg0)
ret0, _ := ret[0].(relationutils.Relations)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FetchLinks indicates an expected call of FetchLinks.
func (mr *MockServiceMockRecorder) FetchLinks(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLinks", reflect.TypeOf((*MockService)(nil).FetchLinks), arg0)
}
// Init mocks base method.
func (m *MockService) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Init", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Init indicates an expected call of Init.
func (mr *MockServiceMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockService)(nil).Init), arg0)
}
// ListAll mocks base method.
func (m *MockService) ListAll(arg0 ...relation.FetchOption) (relationutils.Relations, error) {
m.ctrl.T.Helper()
varargs := []any{}
for _, a := range arg0 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "ListAll", varargs...)
ret0, _ := ret[0].(relationutils.Relations)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListAll indicates an expected call of ListAll.
func (mr *MockServiceMockRecorder) ListAll(arg0 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAll", reflect.TypeOf((*MockService)(nil).ListAll), arg0...)
}
// Name mocks base method.
func (m *MockService) Name() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Name")
ret0, _ := ret[0].(string)
return ret0
}
// Name indicates an expected call of Name.
func (mr *MockServiceMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockService)(nil).Name))
}
// ValidateFormat mocks base method.
func (m *MockService) ValidateFormat(arg0 string, arg1 *types.Value) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ValidateFormat", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ValidateFormat indicates an expected call of ValidateFormat.
func (mr *MockServiceMockRecorder) ValidateFormat(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateFormat", reflect.TypeOf((*MockService)(nil).ValidateFormat), arg0, arg1)
}

View file

@ -18,9 +18,9 @@ import (
state "github.com/anyproto/anytype-heart/core/block/editor/state"
source "github.com/anyproto/anytype-heart/core/block/source"
domain "github.com/anyproto/anytype-heart/core/domain"
pb "github.com/anyproto/anytype-heart/pb"
smartblock "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
model "github.com/anyproto/anytype-heart/pkg/lib/pb/model"
)
// MockService is a mock of Service interface.
@ -62,18 +62,18 @@ func (mr *MockServiceMockRecorder) DetailsFromIdBasedSource(arg0 any) *gomock.Ca
}
// IDsListerBySmartblockType mocks base method.
func (m *MockService) IDsListerBySmartblockType(arg0 string, arg1 smartblock.SmartBlockType) (source.IDsLister, error) {
func (m *MockService) IDsListerBySmartblockType(arg0 smartblock.SmartBlockType) (source.IDsLister, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IDsListerBySmartblockType", arg0, arg1)
ret := m.ctrl.Call(m, "IDsListerBySmartblockType", arg0)
ret0, _ := ret[0].(source.IDsLister)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// IDsListerBySmartblockType indicates an expected call of IDsListerBySmartblockType.
func (mr *MockServiceMockRecorder) IDsListerBySmartblockType(arg0, arg1 any) *gomock.Call {
func (mr *MockServiceMockRecorder) IDsListerBySmartblockType(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IDsListerBySmartblockType", reflect.TypeOf((*MockService)(nil).IDsListerBySmartblockType), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IDsListerBySmartblockType", reflect.TypeOf((*MockService)(nil).IDsListerBySmartblockType), arg0)
}
// Init mocks base method.
@ -120,7 +120,7 @@ func (mr *MockServiceMockRecorder) NewSource(arg0, arg1, arg2, arg3 any) *gomock
}
// NewStaticSource mocks base method.
func (m *MockService) NewStaticSource(arg0 domain.FullID, arg1 smartblock.SmartBlockType, arg2 *state.State, arg3 func(source.PushChangeParams) (string, error)) source.SourceWithType {
func (m *MockService) NewStaticSource(arg0 string, arg1 model.SmartBlockType, arg2 *state.State, arg3 func(source.PushChangeParams) (string, error)) source.SourceWithType {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewStaticSource", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(source.SourceWithType)
@ -134,17 +134,15 @@ func (mr *MockServiceMockRecorder) NewStaticSource(arg0, arg1, arg2, arg3 any) *
}
// RegisterStaticSource mocks base method.
func (m *MockService) RegisterStaticSource(arg0 source.Source) error {
func (m *MockService) RegisterStaticSource(arg0 string, arg1 source.Source) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RegisterStaticSource", arg0)
ret0, _ := ret[0].(error)
return ret0
m.ctrl.Call(m, "RegisterStaticSource", arg0, arg1)
}
// RegisterStaticSource indicates an expected call of RegisterStaticSource.
func (mr *MockServiceMockRecorder) RegisterStaticSource(arg0 any) *gomock.Call {
func (mr *MockServiceMockRecorder) RegisterStaticSource(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterStaticSource", reflect.TypeOf((*MockService)(nil).RegisterStaticSource), arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterStaticSource", reflect.TypeOf((*MockService)(nil).RegisterStaticSource), arg0, arg1)
}
// RemoveStaticSource mocks base method.
@ -282,25 +280,11 @@ func (mr *MockSourceMockRecorder) ReadOnly() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadOnly", reflect.TypeOf((*MockSource)(nil).ReadOnly))
}
// SpaceID mocks base method.
func (m *MockSource) SpaceID() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SpaceID")
ret0, _ := ret[0].(string)
return ret0
}
// SpaceID indicates an expected call of SpaceID.
func (mr *MockSourceMockRecorder) SpaceID() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceID", reflect.TypeOf((*MockSource)(nil).SpaceID))
}
// Type mocks base method.
func (m *MockSource) Type() smartblock.SmartBlockType {
func (m *MockSource) Type() model.SmartBlockType {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Type")
ret0, _ := ret[0].(smartblock.SmartBlockType)
ret0, _ := ret[0].(model.SmartBlockType)
return ret0
}

View file

@ -1,6 +1,10 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/space (interfaces: Service)
//
// Generated by this command:
//
// mockgen -package mockSpace -destination space_mock.go github.com/anyproto/anytype-heart/space Service
//
// Package mockSpace is a generated GoMock package.
package mockSpace
@ -63,7 +67,7 @@ func (m *MockService) AccountSpace(arg0 context.Context) (commonspace.Space, err
}
// AccountSpace indicates an expected call of AccountSpace.
func (mr *MockServiceMockRecorder) AccountSpace(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) AccountSpace(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AccountSpace", reflect.TypeOf((*MockService)(nil).AccountSpace), arg0)
}
@ -77,7 +81,7 @@ func (m *MockService) Close(arg0 context.Context) error {
}
// Close indicates an expected call of Close.
func (mr *MockServiceMockRecorder) Close(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Close(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockService)(nil).Close), arg0)
}
@ -107,7 +111,7 @@ func (m *MockService) DeleteAccount(arg0 context.Context, arg1 bool) (space.Stat
}
// DeleteAccount indicates an expected call of DeleteAccount.
func (mr *MockServiceMockRecorder) DeleteAccount(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) DeleteAccount(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAccount", reflect.TypeOf((*MockService)(nil).DeleteAccount), arg0, arg1)
}
@ -122,7 +126,7 @@ func (m *MockService) DeleteSpace(arg0 context.Context, arg1 string, arg2 bool)
}
// DeleteSpace indicates an expected call of DeleteSpace.
func (mr *MockServiceMockRecorder) DeleteSpace(arg0, arg1, arg2 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) DeleteSpace(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSpace", reflect.TypeOf((*MockService)(nil).DeleteSpace), arg0, arg1, arg2)
}
@ -137,7 +141,7 @@ func (m *MockService) DeriveSpace(arg0 context.Context, arg1 commonspace.SpaceDe
}
// DeriveSpace indicates an expected call of DeriveSpace.
func (mr *MockServiceMockRecorder) DeriveSpace(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) DeriveSpace(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeriveSpace", reflect.TypeOf((*MockService)(nil).DeriveSpace), arg0, arg1)
}
@ -152,7 +156,7 @@ func (m *MockService) GetSpace(arg0 context.Context, arg1 string) (commonspace.S
}
// GetSpace indicates an expected call of GetSpace.
func (mr *MockServiceMockRecorder) GetSpace(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) GetSpace(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpace", reflect.TypeOf((*MockService)(nil).GetSpace), arg0, arg1)
}
@ -166,7 +170,7 @@ func (m *MockService) Init(arg0 *app.App) error {
}
// Init indicates an expected call of Init.
func (mr *MockServiceMockRecorder) Init(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockService)(nil).Init), arg0)
}
@ -194,7 +198,7 @@ func (m *MockService) Run(arg0 context.Context) error {
}
// Run indicates an expected call of Run.
func (mr *MockServiceMockRecorder) Run(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Run(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockService)(nil).Run), arg0)
}

View file

@ -1,6 +1,10 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/anytype-heart/core/syncstatus (interfaces: Service)
//
// Generated by this command:
//
// mockgen -package mockStatus -destination status_mock.go github.com/anyproto/anytype-heart/core/syncstatus Service
//
// Package mockStatus is a generated GoMock package.
package mockStatus
@ -44,7 +48,7 @@ func (m *MockService) Close(arg0 context.Context) error {
}
// Close indicates an expected call of Close.
func (mr *MockServiceMockRecorder) Close(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Close(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockService)(nil).Close), arg0)
}
@ -58,7 +62,7 @@ func (m *MockService) Init(arg0 *app.App) error {
}
// Init indicates an expected call of Init.
func (mr *MockServiceMockRecorder) Init(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockService)(nil).Init), arg0)
}
@ -86,7 +90,7 @@ func (m *MockService) OnFileUpload(arg0, arg1 string) error {
}
// OnFileUpload indicates an expected call of OnFileUpload.
func (mr *MockServiceMockRecorder) OnFileUpload(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) OnFileUpload(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnFileUpload", reflect.TypeOf((*MockService)(nil).OnFileUpload), arg0, arg1)
}
@ -100,34 +104,34 @@ func (m *MockService) Run(arg0 context.Context) error {
}
// Run indicates an expected call of Run.
func (mr *MockServiceMockRecorder) Run(arg0 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Run(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockService)(nil).Run), arg0)
}
// Unwatch mocks base method.
func (m *MockService) Unwatch(arg0, arg1 string) {
func (m *MockService) Unwatch(arg0 string) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Unwatch", arg0, arg1)
m.ctrl.Call(m, "Unwatch", arg0)
}
// Unwatch indicates an expected call of Unwatch.
func (mr *MockServiceMockRecorder) Unwatch(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Unwatch(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unwatch", reflect.TypeOf((*MockService)(nil).Unwatch), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unwatch", reflect.TypeOf((*MockService)(nil).Unwatch), arg0)
}
// Watch mocks base method.
func (m *MockService) Watch(arg0, arg1 string, arg2 func() []string) (bool, error) {
func (m *MockService) Watch(arg0 string, arg1 func() []string) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Watch", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "Watch", arg0, arg1)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Watch indicates an expected call of Watch.
func (mr *MockServiceMockRecorder) Watch(arg0, arg1, arg2 interface{}) *gomock.Call {
func (mr *MockServiceMockRecorder) Watch(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Watch", reflect.TypeOf((*MockService)(nil).Watch), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Watch", reflect.TypeOf((*MockService)(nil).Watch), arg0, arg1)
}

View file

@ -21,6 +21,7 @@ import (
database "github.com/anyproto/anytype-heart/pkg/lib/database"
ftsearch "github.com/anyproto/anytype-heart/pkg/lib/localstore/ftsearch"
model "github.com/anyproto/anytype-heart/pkg/lib/pb/model"
schema "github.com/anyproto/anytype-heart/pkg/lib/schema"
)
// MockObjectStore is a mock of ObjectStore interface.
@ -145,19 +146,38 @@ func (mr *MockObjectStoreMockRecorder) GetAccountStatus() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountStatus", reflect.TypeOf((*MockObjectStore)(nil).GetAccountStatus))
}
// GetByIDs mocks base method.
func (m *MockObjectStore) GetByIDs(arg0 string, arg1 []string) ([]*model.ObjectInfo, error) {
// GetAggregatedOptions mocks base method.
func (m *MockObjectStore) GetAggregatedOptions(arg0 string) ([]*model.RelationOption, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByIDs", arg0, arg1)
ret := m.ctrl.Call(m, "GetAggregatedOptions", arg0)
ret0, _ := ret[0].([]*model.RelationOption)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetAggregatedOptions indicates an expected call of GetAggregatedOptions.
func (mr *MockObjectStoreMockRecorder) GetAggregatedOptions(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedOptions", reflect.TypeOf((*MockObjectStore)(nil).GetAggregatedOptions), arg0)
}
// GetByIDs mocks base method.
func (m *MockObjectStore) GetByIDs(arg0 ...string) ([]*model.ObjectInfo, error) {
m.ctrl.T.Helper()
varargs := []any{}
for _, a := range arg0 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "GetByIDs", varargs...)
ret0, _ := ret[0].([]*model.ObjectInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByIDs indicates an expected call of GetByIDs.
func (mr *MockObjectStoreMockRecorder) GetByIDs(arg0, arg1 any) *gomock.Call {
func (mr *MockObjectStoreMockRecorder) GetByIDs(arg0 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByIDs", reflect.TypeOf((*MockObjectStore)(nil).GetByIDs), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByIDs", reflect.TypeOf((*MockObjectStore)(nil).GetByIDs), arg0...)
}
// GetChecksums mocks base method.
@ -175,6 +195,21 @@ func (mr *MockObjectStoreMockRecorder) GetChecksums() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChecksums", reflect.TypeOf((*MockObjectStore)(nil).GetChecksums))
}
// GetCurrentWorkspaceID mocks base method.
func (m *MockObjectStore) GetCurrentWorkspaceID() (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCurrentWorkspaceID")
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetCurrentWorkspaceID indicates an expected call of GetCurrentWorkspaceID.
func (mr *MockObjectStoreMockRecorder) GetCurrentWorkspaceID() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentWorkspaceID", reflect.TypeOf((*MockObjectStore)(nil).GetCurrentWorkspaceID))
}
// GetDetails mocks base method.
func (m *MockObjectStore) GetDetails(arg0 string) (*model.ObjectDetails, error) {
m.ctrl.T.Helper()
@ -220,6 +255,36 @@ func (mr *MockObjectStoreMockRecorder) GetLastIndexedHeadsHash(arg0 any) *gomock
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastIndexedHeadsHash", reflect.TypeOf((*MockObjectStore)(nil).GetLastIndexedHeadsHash), arg0)
}
// GetObjectType mocks base method.
func (m *MockObjectStore) GetObjectType(arg0 string) (*model.ObjectType, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetObjectType", arg0)
ret0, _ := ret[0].(*model.ObjectType)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetObjectType indicates an expected call of GetObjectType.
func (mr *MockObjectStoreMockRecorder) GetObjectType(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectType", reflect.TypeOf((*MockObjectStore)(nil).GetObjectType), arg0)
}
// GetObjectTypes mocks base method.
func (m *MockObjectStore) GetObjectTypes(arg0 []string) ([]*model.ObjectType, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetObjectTypes", arg0)
ret0, _ := ret[0].([]*model.ObjectType)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetObjectTypes indicates an expected call of GetObjectTypes.
func (mr *MockObjectStoreMockRecorder) GetObjectTypes(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectTypes", reflect.TypeOf((*MockObjectStore)(nil).GetObjectTypes), arg0)
}
// GetOutboundLinksByID mocks base method.
func (m *MockObjectStore) GetOutboundLinksByID(arg0 string) ([]string, error) {
m.ctrl.T.Helper()
@ -235,19 +300,49 @@ func (mr *MockObjectStoreMockRecorder) GetOutboundLinksByID(arg0 any) *gomock.Ca
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOutboundLinksByID", reflect.TypeOf((*MockObjectStore)(nil).GetOutboundLinksByID), arg0)
}
// GetWithLinksInfoByID mocks base method.
func (m *MockObjectStore) GetWithLinksInfoByID(arg0, arg1 string) (*model.ObjectInfoWithLinks, error) {
// GetRelationByID mocks base method.
func (m *MockObjectStore) GetRelationByID(arg0 string) (*model.Relation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetWithLinksInfoByID", arg0, arg1)
ret := m.ctrl.Call(m, "GetRelationByID", arg0)
ret0, _ := ret[0].(*model.Relation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetRelationByID indicates an expected call of GetRelationByID.
func (mr *MockObjectStoreMockRecorder) GetRelationByID(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRelationByID", reflect.TypeOf((*MockObjectStore)(nil).GetRelationByID), arg0)
}
// GetRelationByKey mocks base method.
func (m *MockObjectStore) GetRelationByKey(arg0 string) (*model.Relation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetRelationByKey", arg0)
ret0, _ := ret[0].(*model.Relation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetRelationByKey indicates an expected call of GetRelationByKey.
func (mr *MockObjectStoreMockRecorder) GetRelationByKey(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRelationByKey", reflect.TypeOf((*MockObjectStore)(nil).GetRelationByKey), arg0)
}
// GetWithLinksInfoByID mocks base method.
func (m *MockObjectStore) GetWithLinksInfoByID(arg0 string) (*model.ObjectInfoWithLinks, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetWithLinksInfoByID", arg0)
ret0, _ := ret[0].(*model.ObjectInfoWithLinks)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetWithLinksInfoByID indicates an expected call of GetWithLinksInfoByID.
func (mr *MockObjectStoreMockRecorder) GetWithLinksInfoByID(arg0, arg1 any) *gomock.Call {
func (mr *MockObjectStoreMockRecorder) GetWithLinksInfoByID(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWithLinksInfoByID", reflect.TypeOf((*MockObjectStore)(nil).GetWithLinksInfoByID), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWithLinksInfoByID", reflect.TypeOf((*MockObjectStore)(nil).GetWithLinksInfoByID), arg0)
}
// HasIDs mocks base method.
@ -269,6 +364,21 @@ func (mr *MockObjectStoreMockRecorder) HasIDs(arg0 ...any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasIDs", reflect.TypeOf((*MockObjectStore)(nil).HasIDs), arg0...)
}
// HasObjectType mocks base method.
func (m *MockObjectStore) HasObjectType(arg0 string) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HasObjectType", arg0)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// HasObjectType indicates an expected call of HasObjectType.
func (mr *MockObjectStoreMockRecorder) HasObjectType(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasObjectType", reflect.TypeOf((*MockObjectStore)(nil).HasObjectType), arg0)
}
// Init mocks base method.
func (m *MockObjectStore) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
@ -284,18 +394,18 @@ func (mr *MockObjectStoreMockRecorder) Init(arg0 any) *gomock.Call {
}
// List mocks base method.
func (m *MockObjectStore) List(arg0 string) ([]*model.ObjectInfo, error) {
func (m *MockObjectStore) List() ([]*model.ObjectInfo, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List", arg0)
ret := m.ctrl.Call(m, "List")
ret0, _ := ret[0].([]*model.ObjectInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List.
func (mr *MockObjectStoreMockRecorder) List(arg0 any) *gomock.Call {
func (mr *MockObjectStoreMockRecorder) List() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockObjectStore)(nil).List), arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockObjectStore)(nil).List))
}
// ListIDsFromFullTextQueue mocks base method.
@ -343,9 +453,9 @@ func (mr *MockObjectStoreMockRecorder) Name() *gomock.Call {
}
// Query mocks base method.
func (m *MockObjectStore) Query(arg0 database.Query) ([]database.Record, int, error) {
func (m *MockObjectStore) Query(arg0 schema.Schema, arg1 database.Query) ([]database.Record, int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Query", arg0)
ret := m.ctrl.Call(m, "Query", arg0, arg1)
ret0, _ := ret[0].([]database.Record)
ret1, _ := ret[1].(int)
ret2, _ := ret[2].(error)
@ -353,9 +463,9 @@ func (m *MockObjectStore) Query(arg0 database.Query) ([]database.Record, int, er
}
// Query indicates an expected call of Query.
func (mr *MockObjectStoreMockRecorder) Query(arg0 any) *gomock.Call {
func (mr *MockObjectStoreMockRecorder) Query(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockObjectStore)(nil).Query), arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockObjectStore)(nil).Query), arg0, arg1)
}
// QueryByID mocks base method.
@ -420,6 +530,20 @@ func (mr *MockObjectStoreMockRecorder) QueryRaw(arg0, arg1, arg2 any) *gomock.Ca
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRaw", reflect.TypeOf((*MockObjectStore)(nil).QueryRaw), arg0, arg1, arg2)
}
// RemoveCurrentWorkspaceID mocks base method.
func (m *MockObjectStore) RemoveCurrentWorkspaceID() error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RemoveCurrentWorkspaceID")
ret0, _ := ret[0].(error)
return ret0
}
// RemoveCurrentWorkspaceID indicates an expected call of RemoveCurrentWorkspaceID.
func (mr *MockObjectStoreMockRecorder) RemoveCurrentWorkspaceID() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCurrentWorkspaceID", reflect.TypeOf((*MockObjectStore)(nil).RemoveCurrentWorkspaceID))
}
// RemoveIDsFromFullTextQueue mocks base method.
func (m *MockObjectStore) RemoveIDsFromFullTextQueue(arg0 []string) {
m.ctrl.T.Helper()
@ -488,6 +612,20 @@ func (mr *MockObjectStoreMockRecorder) SaveLastIndexedHeadsHash(arg0, arg1 any)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveLastIndexedHeadsHash", reflect.TypeOf((*MockObjectStore)(nil).SaveLastIndexedHeadsHash), arg0, arg1)
}
// SetCurrentWorkspaceID mocks base method.
func (m *MockObjectStore) SetCurrentWorkspaceID(arg0 string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetCurrentWorkspaceID", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// SetCurrentWorkspaceID indicates an expected call of SetCurrentWorkspaceID.
func (mr *MockObjectStoreMockRecorder) SetCurrentWorkspaceID(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCurrentWorkspaceID", reflect.TypeOf((*MockObjectStore)(nil).SetCurrentWorkspaceID), arg0)
}
// SubscribeForAll mocks base method.
func (m *MockObjectStore) SubscribeForAll(arg0 func(database.Record)) {
m.ctrl.T.Helper()

View file

@ -68,21 +68,6 @@ func (mr *MockSmartBlockTypeProviderMockRecorder) Name() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockSmartBlockTypeProvider)(nil).Name))
}
// PartitionIDsByType mocks base method.
func (m *MockSmartBlockTypeProvider) PartitionIDsByType(arg0 string, arg1 []string) (map[smartblock.SmartBlockType][]string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PartitionIDsByType", arg0, arg1)
ret0, _ := ret[0].(map[smartblock.SmartBlockType][]string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// PartitionIDsByType indicates an expected call of PartitionIDsByType.
func (mr *MockSmartBlockTypeProviderMockRecorder) PartitionIDsByType(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PartitionIDsByType", reflect.TypeOf((*MockSmartBlockTypeProvider)(nil).PartitionIDsByType), arg0, arg1)
}
// RegisterStaticType mocks base method.
func (m *MockSmartBlockTypeProvider) RegisterStaticType(arg0 string, arg1 smartblock.SmartBlockType) {
m.ctrl.T.Helper()
@ -96,16 +81,16 @@ func (mr *MockSmartBlockTypeProviderMockRecorder) RegisterStaticType(arg0, arg1
}
// Type mocks base method.
func (m *MockSmartBlockTypeProvider) Type(arg0, arg1 string) (smartblock.SmartBlockType, error) {
func (m *MockSmartBlockTypeProvider) Type(arg0 string) (smartblock.SmartBlockType, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Type", arg0, arg1)
ret := m.ctrl.Call(m, "Type", arg0)
ret0, _ := ret[0].(smartblock.SmartBlockType)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Type indicates an expected call of Type.
func (mr *MockSmartBlockTypeProviderMockRecorder) Type(arg0, arg1 any) *gomock.Call {
func (mr *MockSmartBlockTypeProviderMockRecorder) Type(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*MockSmartBlockTypeProvider)(nil).Type), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*MockSmartBlockTypeProvider)(nil).Type), arg0)
}