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

GO-2548 Fix space tests

This commit is contained in:
mcrakhman 2023-12-22 17:36:48 +01:00
parent f74503e8dc
commit bef4a48fff
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
4 changed files with 66 additions and 103 deletions

View file

@ -19,8 +19,6 @@ import (
model "github.com/anyproto/anytype-heart/pkg/lib/pb/model"
objectstore "github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore"
pbtypes "github.com/anyproto/anytype-heart/util/pbtypes"
relationutils "github.com/anyproto/anytype-heart/core/relationutils"
@ -239,6 +237,65 @@ func (_c *MockObjectStore_DeleteDetails_Call) RunAndReturn(run func(...string) e
return _c
}
// DeleteLinks provides a mock function with given fields: id
func (_m *MockObjectStore) DeleteLinks(id ...string) error {
_va := make([]interface{}, len(id))
for _i := range id {
_va[_i] = id[_i]
}
var _ca []interface{}
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
if len(ret) == 0 {
panic("no return value specified for DeleteLinks")
}
var r0 error
if rf, ok := ret.Get(0).(func(...string) error); ok {
r0 = rf(id...)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockObjectStore_DeleteLinks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteLinks'
type MockObjectStore_DeleteLinks_Call struct {
*mock.Call
}
// DeleteLinks is a helper method to define mock.On call
// - id ...string
func (_e *MockObjectStore_Expecter) DeleteLinks(id ...interface{}) *MockObjectStore_DeleteLinks_Call {
return &MockObjectStore_DeleteLinks_Call{Call: _e.mock.On("DeleteLinks",
append([]interface{}{}, id...)...)}
}
func (_c *MockObjectStore_DeleteLinks_Call) Run(run func(id ...string)) *MockObjectStore_DeleteLinks_Call {
_c.Call.Run(func(args mock.Arguments) {
variadicArgs := make([]string, len(args)-0)
for i, a := range args[0:] {
if a != nil {
variadicArgs[i] = a.(string)
}
}
run(variadicArgs...)
})
return _c
}
func (_c *MockObjectStore_DeleteLinks_Call) Return(_a0 error) *MockObjectStore_DeleteLinks_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *MockObjectStore_DeleteLinks_Call) RunAndReturn(run func(...string) error) *MockObjectStore_DeleteLinks_Call {
_c.Call.Return(run)
return _c
}
// DeleteObject provides a mock function with given fields: id
func (_m *MockObjectStore) DeleteObject(id string) error {
ret := _m.Called(id)
@ -331,52 +388,6 @@ func (_c *MockObjectStore_DeleteVirtualSpace_Call) RunAndReturn(run func(string)
return _c
}
// EraseIndexes provides a mock function with given fields: spaceId
func (_m *MockObjectStore) EraseIndexes(spaceId string) error {
ret := _m.Called(spaceId)
if len(ret) == 0 {
panic("no return value specified for EraseIndexes")
}
var r0 error
if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(spaceId)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockObjectStore_EraseIndexes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EraseIndexes'
type MockObjectStore_EraseIndexes_Call struct {
*mock.Call
}
// EraseIndexes is a helper method to define mock.On call
// - spaceId string
func (_e *MockObjectStore_Expecter) EraseIndexes(spaceId interface{}) *MockObjectStore_EraseIndexes_Call {
return &MockObjectStore_EraseIndexes_Call{Call: _e.mock.On("EraseIndexes", spaceId)}
}
func (_c *MockObjectStore_EraseIndexes_Call) Run(run func(spaceId string)) *MockObjectStore_EraseIndexes_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(string))
})
return _c
}
func (_c *MockObjectStore_EraseIndexes_Call) Return(_a0 error) *MockObjectStore_EraseIndexes_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *MockObjectStore_EraseIndexes_Call) RunAndReturn(run func(string) error) *MockObjectStore_EraseIndexes_Call {
_c.Call.Return(run)
return _c
}
// FTSearch provides a mock function with given fields:
func (_m *MockObjectStore) FTSearch() ftsearch.FTSearch {
ret := _m.Called()
@ -2621,53 +2632,6 @@ func (_c *MockObjectStore_SaveVirtualSpace_Call) RunAndReturn(run func(string) e
return _c
}
// SubscribeBacklinksUpdate provides a mock function with given fields:
func (_m *MockObjectStore) SubscribeBacklinksUpdate() <-chan objectstore.BacklinksUpdateInfo {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for SubscribeBacklinksUpdate")
}
var r0 <-chan objectstore.BacklinksUpdateInfo
if rf, ok := ret.Get(0).(func() <-chan objectstore.BacklinksUpdateInfo); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(<-chan objectstore.BacklinksUpdateInfo)
}
}
return r0
}
// MockObjectStore_SubscribeBacklinksUpdate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribeBacklinksUpdate'
type MockObjectStore_SubscribeBacklinksUpdate_Call struct {
*mock.Call
}
// SubscribeBacklinksUpdate is a helper method to define mock.On call
func (_e *MockObjectStore_Expecter) SubscribeBacklinksUpdate() *MockObjectStore_SubscribeBacklinksUpdate_Call {
return &MockObjectStore_SubscribeBacklinksUpdate_Call{Call: _e.mock.On("SubscribeBacklinksUpdate")}
}
func (_c *MockObjectStore_SubscribeBacklinksUpdate_Call) Run(run func()) *MockObjectStore_SubscribeBacklinksUpdate_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockObjectStore_SubscribeBacklinksUpdate_Call) Return(_a0 <-chan objectstore.BacklinksUpdateInfo) *MockObjectStore_SubscribeBacklinksUpdate_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *MockObjectStore_SubscribeBacklinksUpdate_Call) RunAndReturn(run func() <-chan objectstore.BacklinksUpdateInfo) *MockObjectStore_SubscribeBacklinksUpdate_Call {
_c.Call.Return(run)
return _c
}
// SubscribeForAll provides a mock function with given fields: callback
func (_m *MockObjectStore) SubscribeForAll(callback func(database.Record)) {
_m.Called(callback)

View file

@ -124,10 +124,6 @@ func (_m *MockSpace) CreateMandatoryObjects(ctx context.Context, space smartbloc
panic("no return value specified for CreateMandatoryObjects")
}
if len(ret) == 0 {
panic("no return value specified for CreateMandatoryObjects")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, smartblock.Space) error); ok {
r0 = rf(ctx, space)

View file

@ -17,6 +17,7 @@ import (
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
"github.com/anyproto/anytype-heart/space/clientspace"
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
"github.com/anyproto/anytype-heart/space/spacecore"
"github.com/anyproto/anytype-heart/space/spacefactory"
"github.com/anyproto/anytype-heart/space/spaceinfo"
@ -231,10 +232,11 @@ func (s *service) Close(ctx context.Context) error {
func (s *service) allIDs() (ids []string) {
s.mu.Lock()
defer s.mu.Unlock()
for id := range s.spaceControllers {
if id != addr.AnytypeMarketplaceWorkspace {
ids = append(ids, id)
for id, sc := range s.spaceControllers {
if id == addr.AnytypeMarketplaceWorkspace || sc.Mode() != mode.ModeLoading {
continue
}
ids = append(ids, id)
}
return
}

View file

@ -17,6 +17,7 @@ import (
"github.com/anyproto/anytype-heart/space/clientspace"
"github.com/anyproto/anytype-heart/space/clientspace/mock_clientspace"
"github.com/anyproto/anytype-heart/space/internal/spacecontroller/mock_spacecontroller"
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
"github.com/anyproto/anytype-heart/space/internal/techspace/mock_techspace"
"github.com/anyproto/anytype-heart/space/spacecore/mock_spacecore"
"github.com/anyproto/anytype-heart/space/spacefactory/mock_spacefactory"
@ -39,7 +40,6 @@ func TestService_Init(t *testing.T) {
fx := newFixture(t, true)
defer fx.finish(t)
})
}
func newFixture(t *testing.T, newAccount bool) *fixture {
@ -110,6 +110,7 @@ func (fx *fixture) expectRun(t *testing.T, newAccount bool) {
lw := lwMock{clientSpace}
prCtrl.EXPECT().Current().Return(lw)
}
prCtrl.EXPECT().Mode().Return(mode.ModeLoading)
ts.EXPECT().Close(mock.Anything).Return(nil)
mpCtrl.EXPECT().Close(mock.Anything).Return(nil)
prCtrl.EXPECT().Close(mock.Anything).Return(nil)