mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 17:44:59 +09:00
GO-4009 Change isNew logic and streampool
This commit is contained in:
parent
0fde7366c7
commit
7b448c3dc7
6 changed files with 874 additions and 81 deletions
|
@ -82,9 +82,15 @@ func (s *store) ReadStoreDoc(ctx context.Context, storeState *storestate.StoreSt
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
// checking if we have any data in the store regarding the tree (i.e. if tree is first arrived or created)
|
||||
allIsNew := false
|
||||
if _, err := tx.GetOrder(s.id); err != nil {
|
||||
allIsNew = true
|
||||
}
|
||||
applier := &storeApply{
|
||||
tx: tx,
|
||||
ot: s.ObjectTree,
|
||||
tx: tx,
|
||||
allIsNew: allIsNew,
|
||||
ot: s.ObjectTree,
|
||||
}
|
||||
if err = applier.Apply(); err != nil {
|
||||
return errors.Join(tx.Rollback(), err)
|
||||
|
|
|
@ -5,14 +5,16 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
|
||||
"github.com/anyproto/anytype-heart/core/block/editor/storestate"
|
||||
"github.com/anyproto/anytype-heart/pb"
|
||||
)
|
||||
|
||||
type storeApply struct {
|
||||
tx *storestate.StoreStateTx
|
||||
ot objecttree.ObjectTree
|
||||
tx *storestate.StoreStateTx
|
||||
ot objecttree.ObjectTree
|
||||
allIsNew bool
|
||||
|
||||
prevOrder string
|
||||
prevChange *objecttree.Change
|
||||
|
@ -25,16 +27,12 @@ func (a *storeApply) Apply() (err error) {
|
|||
maxOrder := a.tx.GetMaxOrder()
|
||||
isEmpty := maxOrder == ""
|
||||
iterErr := a.ot.IterateRoot(UnmarshalStoreChange, func(change *objecttree.Change) bool {
|
||||
// Ignore header
|
||||
if change.Id == a.ot.Id() {
|
||||
// not a new change - remember and continue
|
||||
if !a.allIsNew && !change.IsNew && !isEmpty {
|
||||
a.prevChange = change
|
||||
a.prevOrder = ""
|
||||
return true
|
||||
}
|
||||
// not a new change - remember and continue
|
||||
// if !change.IsNew && !isEmpty {
|
||||
// a.prevChange = change
|
||||
// a.prevOrder = ""
|
||||
// return true
|
||||
// }
|
||||
currOrder, curOrdErr := a.tx.GetOrder(change.Id)
|
||||
if curOrdErr != nil {
|
||||
if !errors.Is(curOrdErr, storestate.ErrOrderNotFound) {
|
||||
|
@ -93,6 +91,10 @@ func (a *storeApply) Apply() (err error) {
|
|||
func (a *storeApply) applyChange(change *objecttree.Change, order string) (err error) {
|
||||
storeChange, ok := change.Model.(*pb.StoreChange)
|
||||
if !ok {
|
||||
// if it is root
|
||||
if _, ok := change.Model.(*treechangeproto.TreeChangeInfo); ok {
|
||||
return a.tx.SetOrder(change.Id, order)
|
||||
}
|
||||
return fmt.Errorf("unexpected change content type: %T", change.Model)
|
||||
}
|
||||
set := storestate.ChangeSet{
|
||||
|
|
|
@ -10,8 +10,11 @@ import (
|
|||
"time"
|
||||
|
||||
anystore "github.com/anyproto/any-store"
|
||||
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree/mock_objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -23,9 +26,77 @@ import (
|
|||
|
||||
var ctx = context.Background()
|
||||
|
||||
func TestStoreApply_RealTree(t *testing.T) {
|
||||
update := func(fx *storeFx, heads []string, chs []*treechangeproto.RawTreeChangeWithId) {
|
||||
tx := fx.RequireTx(t)
|
||||
_, err := fx.realTree.AddRawChangesWithUpdater(ctx, objecttree.RawChangesPayload{
|
||||
NewHeads: heads,
|
||||
RawChanges: chs,
|
||||
}, func(tree objecttree.ObjectTree, md objecttree.Mode) error {
|
||||
applier := &storeApply{
|
||||
tx: tx,
|
||||
ot: fx.realTree,
|
||||
}
|
||||
return applier.Apply()
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, tx.Commit())
|
||||
}
|
||||
assertOrder := func(fx *storeFx, orders []string) {
|
||||
var changes []*objecttree.Change
|
||||
for _, order := range orders {
|
||||
changes = append(changes, testChange(order, false))
|
||||
}
|
||||
tx := fx.RequireTx(t)
|
||||
fx.AssertOrder(t, tx, changes...)
|
||||
}
|
||||
t.Run("new real tree - 1,2,3 then 4,5", func(t *testing.T) {
|
||||
fx := newRealTreeStoreFx(t)
|
||||
newChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
fx.changeCreator.CreateRaw("1", fx.aclList.Head().Id, "0", false, "0"),
|
||||
fx.changeCreator.CreateRaw("2", fx.aclList.Head().Id, "0", false, "1"),
|
||||
fx.changeCreator.CreateRaw("3", fx.aclList.Head().Id, "0", true, "2"),
|
||||
}
|
||||
update(fx, []string{"3"}, newChanges)
|
||||
newChanges = []*treechangeproto.RawTreeChangeWithId{
|
||||
fx.changeCreator.CreateRaw("4", fx.aclList.Head().Id, "0", false, "0"),
|
||||
fx.changeCreator.CreateRaw("5", fx.aclList.Head().Id, "0", true, "4"),
|
||||
}
|
||||
update(fx, []string{"3", "5"}, newChanges)
|
||||
assertOrder(fx, []string{"0", "1", "2", "3", "4", "5"})
|
||||
})
|
||||
t.Run("new real tree - 4,5 then 1,2,3", func(t *testing.T) {
|
||||
fx := newRealTreeStoreFx(t)
|
||||
newChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
fx.changeCreator.CreateRaw("4", fx.aclList.Head().Id, "0", false, "0"),
|
||||
fx.changeCreator.CreateRaw("5", fx.aclList.Head().Id, "0", true, "4"),
|
||||
}
|
||||
update(fx, []string{"5"}, newChanges)
|
||||
newChanges = []*treechangeproto.RawTreeChangeWithId{
|
||||
fx.changeCreator.CreateRaw("1", fx.aclList.Head().Id, "0", false, "0"),
|
||||
fx.changeCreator.CreateRaw("2", fx.aclList.Head().Id, "0", false, "1"),
|
||||
fx.changeCreator.CreateRaw("3", fx.aclList.Head().Id, "0", true, "2"),
|
||||
}
|
||||
update(fx, []string{"3", "5"}, newChanges)
|
||||
assertOrder(fx, []string{"0", "1", "2", "3", "4", "5"})
|
||||
})
|
||||
t.Run("new real tree - 1,2,3,4,5 in one batch", func(t *testing.T) {
|
||||
fx := newRealTreeStoreFx(t)
|
||||
newChanges := []*treechangeproto.RawTreeChangeWithId{
|
||||
fx.changeCreator.CreateRaw("1", fx.aclList.Head().Id, "0", false, "0"),
|
||||
fx.changeCreator.CreateRaw("2", fx.aclList.Head().Id, "0", false, "1"),
|
||||
fx.changeCreator.CreateRaw("3", fx.aclList.Head().Id, "0", true, "2"),
|
||||
fx.changeCreator.CreateRaw("4", fx.aclList.Head().Id, "0", false, "0"),
|
||||
fx.changeCreator.CreateRaw("5", fx.aclList.Head().Id, "0", true, "4"),
|
||||
}
|
||||
update(fx, []string{"3", "4", "5"}, newChanges)
|
||||
assertOrder(fx, []string{"0", "1", "2", "3", "4", "5"})
|
||||
})
|
||||
}
|
||||
|
||||
func TestStoreApply_Apply(t *testing.T) {
|
||||
t.Run("new tree", func(t *testing.T) {
|
||||
fx := newStoreFx(t)
|
||||
fx := newMockTreeStoreFx(t)
|
||||
tx := fx.RequireTx(t)
|
||||
changes := []*objecttree.Change{
|
||||
testChange("1", false),
|
||||
|
@ -36,7 +107,7 @@ func TestStoreApply_Apply(t *testing.T) {
|
|||
require.NoError(t, tx.Commit())
|
||||
})
|
||||
t.Run("insert middle", func(t *testing.T) {
|
||||
fx := newStoreFx(t)
|
||||
fx := newMockTreeStoreFx(t)
|
||||
tx := fx.RequireTx(t)
|
||||
changes := []*objecttree.Change{
|
||||
testChange("1", false),
|
||||
|
@ -62,7 +133,7 @@ func TestStoreApply_Apply(t *testing.T) {
|
|||
require.NoError(t, tx.Commit())
|
||||
})
|
||||
t.Run("append", func(t *testing.T) {
|
||||
fx := newStoreFx(t)
|
||||
fx := newMockTreeStoreFx(t)
|
||||
tx := fx.RequireTx(t)
|
||||
changes := []*objecttree.Change{
|
||||
testChange("1", false),
|
||||
|
@ -87,7 +158,7 @@ func TestStoreApply_Apply(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStoreApply_Apply10000(t *testing.T) {
|
||||
fx := newStoreFx(t)
|
||||
fx := newMockTreeStoreFx(t)
|
||||
tx := fx.RequireTx(t)
|
||||
changes := make([]*objecttree.Change, 100000)
|
||||
for i := range changes {
|
||||
|
@ -96,7 +167,7 @@ func TestStoreApply_Apply10000(t *testing.T) {
|
|||
st := time.Now()
|
||||
applier := &storeApply{
|
||||
tx: tx,
|
||||
ot: fx.tree,
|
||||
ot: fx.mockTree,
|
||||
}
|
||||
fx.ExpectTree(changes...)
|
||||
require.NoError(t, applier.Apply())
|
||||
|
@ -108,13 +179,16 @@ func TestStoreApply_Apply10000(t *testing.T) {
|
|||
}
|
||||
|
||||
type storeFx struct {
|
||||
state *storestate.StoreState
|
||||
tree *mock_objecttree.MockObjectTree
|
||||
db anystore.DB
|
||||
state *storestate.StoreState
|
||||
mockTree *mock_objecttree.MockObjectTree
|
||||
realTree objecttree.ObjectTree
|
||||
changeCreator *objecttree.MockChangeCreator
|
||||
aclList list.AclList
|
||||
db anystore.DB
|
||||
}
|
||||
|
||||
func (fx *storeFx) ExpectTree(changes ...*objecttree.Change) {
|
||||
fx.tree.EXPECT().IterateRoot(gomock.Any(), gomock.Any()).DoAndReturn(func(_ objecttree.ChangeConvertFunc, f objecttree.ChangeIterateFunc) error {
|
||||
fx.mockTree.EXPECT().IterateRoot(gomock.Any(), gomock.Any()).DoAndReturn(func(_ objecttree.ChangeConvertFunc, f objecttree.ChangeIterateFunc) error {
|
||||
for _, ch := range changes {
|
||||
if !f(ch) {
|
||||
return nil
|
||||
|
@ -125,7 +199,7 @@ func (fx *storeFx) ExpectTree(changes ...*objecttree.Change) {
|
|||
}
|
||||
|
||||
func (fx *storeFx) ExpectTreeFrom(fromId string, changes ...*objecttree.Change) {
|
||||
fx.tree.EXPECT().IterateFrom(fromId, gomock.Any(), gomock.Any()).DoAndReturn(func(_ string, _ objecttree.ChangeConvertFunc, f objecttree.ChangeIterateFunc) error {
|
||||
fx.mockTree.EXPECT().IterateFrom(fromId, gomock.Any(), gomock.Any()).DoAndReturn(func(_ string, _ objecttree.ChangeConvertFunc, f objecttree.ChangeIterateFunc) error {
|
||||
for _, ch := range changes {
|
||||
if !f(ch) {
|
||||
return nil
|
||||
|
@ -158,14 +232,14 @@ func (fx *storeFx) AssertOrder(t testing.TB, tx *storestate.StoreStateTx, change
|
|||
func (fx *storeFx) ApplyChanges(t *testing.T, tx *storestate.StoreStateTx, changes ...*objecttree.Change) {
|
||||
applier := &storeApply{
|
||||
tx: tx,
|
||||
ot: fx.tree,
|
||||
ot: fx.mockTree,
|
||||
}
|
||||
fx.ExpectTree(changes...)
|
||||
require.NoError(t, applier.Apply())
|
||||
fx.AssertOrder(t, tx, changes...)
|
||||
}
|
||||
|
||||
func newStoreFx(t testing.TB) *storeFx {
|
||||
func newMockTreeStoreFx(t testing.TB) *storeFx {
|
||||
tmpDir, err := os.MkdirTemp("", "source_store_*")
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -190,12 +264,53 @@ func newStoreFx(t testing.TB) *storeFx {
|
|||
tree.EXPECT().Id().Return("root").AnyTimes()
|
||||
|
||||
return &storeFx{
|
||||
state: state,
|
||||
tree: tree,
|
||||
db: db,
|
||||
state: state,
|
||||
mockTree: tree,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func newRealTreeStoreFx(t testing.TB) *storeFx {
|
||||
tmpDir, err := os.MkdirTemp("", "source_store_*")
|
||||
require.NoError(t, err)
|
||||
|
||||
db, err := anystore.Open(ctx, filepath.Join(tmpDir, "test.db"), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
t.Cleanup(func() {
|
||||
if db != nil {
|
||||
_ = db.Close()
|
||||
}
|
||||
ctrl.Finish()
|
||||
if tmpDir != "" {
|
||||
_ = os.RemoveAll(tmpDir)
|
||||
}
|
||||
})
|
||||
|
||||
state, err := storestate.New(ctx, "source_test", db, storestate.DefaultHandler{Name: "default"})
|
||||
require.NoError(t, err)
|
||||
aclList, _ := prepareAclList(t)
|
||||
objTree, err := buildTree(aclList)
|
||||
require.NoError(t, err)
|
||||
fx := &storeFx{
|
||||
state: state,
|
||||
realTree: objTree,
|
||||
aclList: aclList,
|
||||
changeCreator: objecttree.NewMockChangeCreator(),
|
||||
db: db,
|
||||
}
|
||||
tx := fx.RequireTx(t)
|
||||
applier := &storeApply{
|
||||
tx: tx,
|
||||
allIsNew: true,
|
||||
ot: fx.realTree,
|
||||
}
|
||||
require.NoError(t, applier.Apply())
|
||||
require.NoError(t, tx.Commit())
|
||||
return fx
|
||||
}
|
||||
|
||||
func testChange(id string, isNew bool) *objecttree.Change {
|
||||
_, pub, _ := crypto.GenerateRandomEd25519KeyPair()
|
||||
|
||||
|
@ -206,3 +321,23 @@ func testChange(id string, isNew bool) *objecttree.Change {
|
|||
Identity: pub,
|
||||
}
|
||||
}
|
||||
|
||||
func prepareAclList(t testing.TB) (list.AclList, *accountdata.AccountKeys) {
|
||||
randKeys, err := accountdata.NewRandom()
|
||||
require.NoError(t, err)
|
||||
aclList, err := list.NewTestDerivedAcl("spaceId", randKeys)
|
||||
require.NoError(t, err, "building acl list should be without error")
|
||||
|
||||
return aclList, randKeys
|
||||
}
|
||||
|
||||
func buildTree(aclList list.AclList) (objecttree.ObjectTree, error) {
|
||||
changeCreator := objecttree.NewMockChangeCreator()
|
||||
treeStorage := changeCreator.CreateNewTreeStorage("0", aclList.Head().Id, false)
|
||||
tree, err := objecttree.BuildTestableTree(treeStorage, aclList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tree.SetFlusher(objecttree.MarkNewChangeFlusher())
|
||||
return tree, nil
|
||||
}
|
||||
|
|
703
core/filestorage/rpcstore/mock_rpcstore/mock_RpcStore.go
Normal file
703
core/filestorage/rpcstore/mock_rpcstore/mock_RpcStore.go
Normal file
|
@ -0,0 +1,703 @@
|
|||
// Code generated by mockery. DO NOT EDIT.
|
||||
|
||||
package mock_rpcstore
|
||||
|
||||
import (
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
|
||||
context "context"
|
||||
|
||||
domain "github.com/anyproto/anytype-heart/core/domain"
|
||||
|
||||
fileproto "github.com/anyproto/any-sync/commonfile/fileproto"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// MockRpcStore is an autogenerated mock type for the RpcStore type
|
||||
type MockRpcStore struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockRpcStore_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockRpcStore) EXPECT() *MockRpcStore_Expecter {
|
||||
return &MockRpcStore_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AccountInfo provides a mock function with given fields: ctx
|
||||
func (_m *MockRpcStore) AccountInfo(ctx context.Context) (*fileproto.AccountInfoResponse, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AccountInfo")
|
||||
}
|
||||
|
||||
var r0 *fileproto.AccountInfoResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) (*fileproto.AccountInfoResponse, error)); ok {
|
||||
return rf(ctx)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) *fileproto.AccountInfoResponse); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*fileproto.AccountInfoResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRpcStore_AccountInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AccountInfo'
|
||||
type MockRpcStore_AccountInfo_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AccountInfo is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockRpcStore_Expecter) AccountInfo(ctx interface{}) *MockRpcStore_AccountInfo_Call {
|
||||
return &MockRpcStore_AccountInfo_Call{Call: _e.mock.On("AccountInfo", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_AccountInfo_Call) Run(run func(ctx context.Context)) *MockRpcStore_AccountInfo_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_AccountInfo_Call) Return(info *fileproto.AccountInfoResponse, err error) *MockRpcStore_AccountInfo_Call {
|
||||
_c.Call.Return(info, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_AccountInfo_Call) RunAndReturn(run func(context.Context) (*fileproto.AccountInfoResponse, error)) *MockRpcStore_AccountInfo_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Add provides a mock function with given fields: ctx, b
|
||||
func (_m *MockRpcStore) Add(ctx context.Context, b []blocks.Block) error {
|
||||
ret := _m.Called(ctx, b)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Add")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []blocks.Block) error); ok {
|
||||
r0 = rf(ctx, b)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_Add_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Add'
|
||||
type MockRpcStore_Add_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Add is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - b []blocks.Block
|
||||
func (_e *MockRpcStore_Expecter) Add(ctx interface{}, b interface{}) *MockRpcStore_Add_Call {
|
||||
return &MockRpcStore_Add_Call{Call: _e.mock.On("Add", ctx, b)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Add_Call) Run(run func(ctx context.Context, b []blocks.Block)) *MockRpcStore_Add_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].([]blocks.Block))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Add_Call) Return(_a0 error) *MockRpcStore_Add_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Add_Call) RunAndReturn(run func(context.Context, []blocks.Block) error) *MockRpcStore_Add_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddToFile provides a mock function with given fields: ctx, spaceId, fileId, bs
|
||||
func (_m *MockRpcStore) AddToFile(ctx context.Context, spaceId string, fileId domain.FileId, bs []blocks.Block) error {
|
||||
ret := _m.Called(ctx, spaceId, fileId, bs)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AddToFile")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, domain.FileId, []blocks.Block) error); ok {
|
||||
r0 = rf(ctx, spaceId, fileId, bs)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_AddToFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddToFile'
|
||||
type MockRpcStore_AddToFile_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AddToFile is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - spaceId string
|
||||
// - fileId domain.FileId
|
||||
// - bs []blocks.Block
|
||||
func (_e *MockRpcStore_Expecter) AddToFile(ctx interface{}, spaceId interface{}, fileId interface{}, bs interface{}) *MockRpcStore_AddToFile_Call {
|
||||
return &MockRpcStore_AddToFile_Call{Call: _e.mock.On("AddToFile", ctx, spaceId, fileId, bs)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_AddToFile_Call) Run(run func(ctx context.Context, spaceId string, fileId domain.FileId, bs []blocks.Block)) *MockRpcStore_AddToFile_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string), args[2].(domain.FileId), args[3].([]blocks.Block))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_AddToFile_Call) Return(err error) *MockRpcStore_AddToFile_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_AddToFile_Call) RunAndReturn(run func(context.Context, string, domain.FileId, []blocks.Block) error) *MockRpcStore_AddToFile_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// BindCids provides a mock function with given fields: ctx, spaceID, fileId, cids
|
||||
func (_m *MockRpcStore) BindCids(ctx context.Context, spaceID string, fileId domain.FileId, cids []cid.Cid) error {
|
||||
ret := _m.Called(ctx, spaceID, fileId, cids)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for BindCids")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, domain.FileId, []cid.Cid) error); ok {
|
||||
r0 = rf(ctx, spaceID, fileId, cids)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_BindCids_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BindCids'
|
||||
type MockRpcStore_BindCids_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// BindCids is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - spaceID string
|
||||
// - fileId domain.FileId
|
||||
// - cids []cid.Cid
|
||||
func (_e *MockRpcStore_Expecter) BindCids(ctx interface{}, spaceID interface{}, fileId interface{}, cids interface{}) *MockRpcStore_BindCids_Call {
|
||||
return &MockRpcStore_BindCids_Call{Call: _e.mock.On("BindCids", ctx, spaceID, fileId, cids)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_BindCids_Call) Run(run func(ctx context.Context, spaceID string, fileId domain.FileId, cids []cid.Cid)) *MockRpcStore_BindCids_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string), args[2].(domain.FileId), args[3].([]cid.Cid))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_BindCids_Call) Return(err error) *MockRpcStore_BindCids_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_BindCids_Call) RunAndReturn(run func(context.Context, string, domain.FileId, []cid.Cid) error) *MockRpcStore_BindCids_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// CheckAvailability provides a mock function with given fields: ctx, spaceID, cids
|
||||
func (_m *MockRpcStore) CheckAvailability(ctx context.Context, spaceID string, cids []cid.Cid) ([]*fileproto.BlockAvailability, error) {
|
||||
ret := _m.Called(ctx, spaceID, cids)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CheckAvailability")
|
||||
}
|
||||
|
||||
var r0 []*fileproto.BlockAvailability
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, []cid.Cid) ([]*fileproto.BlockAvailability, error)); ok {
|
||||
return rf(ctx, spaceID, cids)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, []cid.Cid) []*fileproto.BlockAvailability); ok {
|
||||
r0 = rf(ctx, spaceID, cids)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*fileproto.BlockAvailability)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, []cid.Cid) error); ok {
|
||||
r1 = rf(ctx, spaceID, cids)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRpcStore_CheckAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckAvailability'
|
||||
type MockRpcStore_CheckAvailability_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// CheckAvailability is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - spaceID string
|
||||
// - cids []cid.Cid
|
||||
func (_e *MockRpcStore_Expecter) CheckAvailability(ctx interface{}, spaceID interface{}, cids interface{}) *MockRpcStore_CheckAvailability_Call {
|
||||
return &MockRpcStore_CheckAvailability_Call{Call: _e.mock.On("CheckAvailability", ctx, spaceID, cids)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_CheckAvailability_Call) Run(run func(ctx context.Context, spaceID string, cids []cid.Cid)) *MockRpcStore_CheckAvailability_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string), args[2].([]cid.Cid))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_CheckAvailability_Call) Return(checkResult []*fileproto.BlockAvailability, err error) *MockRpcStore_CheckAvailability_Call {
|
||||
_c.Call.Return(checkResult, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_CheckAvailability_Call) RunAndReturn(run func(context.Context, string, []cid.Cid) ([]*fileproto.BlockAvailability, error)) *MockRpcStore_CheckAvailability_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, c
|
||||
func (_m *MockRpcStore) Delete(ctx context.Context, c cid.Cid) error {
|
||||
ret := _m.Called(ctx, c)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Delete")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, cid.Cid) error); ok {
|
||||
r0 = rf(ctx, c)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete'
|
||||
type MockRpcStore_Delete_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Delete is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - c cid.Cid
|
||||
func (_e *MockRpcStore_Expecter) Delete(ctx interface{}, c interface{}) *MockRpcStore_Delete_Call {
|
||||
return &MockRpcStore_Delete_Call{Call: _e.mock.On("Delete", ctx, c)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Delete_Call) Run(run func(ctx context.Context, c cid.Cid)) *MockRpcStore_Delete_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(cid.Cid))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Delete_Call) Return(_a0 error) *MockRpcStore_Delete_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Delete_Call) RunAndReturn(run func(context.Context, cid.Cid) error) *MockRpcStore_Delete_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// DeleteFiles provides a mock function with given fields: ctx, spaceId, fileIds
|
||||
func (_m *MockRpcStore) DeleteFiles(ctx context.Context, spaceId string, fileIds ...domain.FileId) error {
|
||||
_va := make([]interface{}, len(fileIds))
|
||||
for _i := range fileIds {
|
||||
_va[_i] = fileIds[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, spaceId)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeleteFiles")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, ...domain.FileId) error); ok {
|
||||
r0 = rf(ctx, spaceId, fileIds...)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_DeleteFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteFiles'
|
||||
type MockRpcStore_DeleteFiles_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// DeleteFiles is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - spaceId string
|
||||
// - fileIds ...domain.FileId
|
||||
func (_e *MockRpcStore_Expecter) DeleteFiles(ctx interface{}, spaceId interface{}, fileIds ...interface{}) *MockRpcStore_DeleteFiles_Call {
|
||||
return &MockRpcStore_DeleteFiles_Call{Call: _e.mock.On("DeleteFiles",
|
||||
append([]interface{}{ctx, spaceId}, fileIds...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_DeleteFiles_Call) Run(run func(ctx context.Context, spaceId string, fileIds ...domain.FileId)) *MockRpcStore_DeleteFiles_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]domain.FileId, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(domain.FileId)
|
||||
}
|
||||
}
|
||||
run(args[0].(context.Context), args[1].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_DeleteFiles_Call) Return(err error) *MockRpcStore_DeleteFiles_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_DeleteFiles_Call) RunAndReturn(run func(context.Context, string, ...domain.FileId) error) *MockRpcStore_DeleteFiles_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// FilesInfo provides a mock function with given fields: ctx, spaceId, fileIds
|
||||
func (_m *MockRpcStore) FilesInfo(ctx context.Context, spaceId string, fileIds ...domain.FileId) ([]*fileproto.FileInfo, error) {
|
||||
_va := make([]interface{}, len(fileIds))
|
||||
for _i := range fileIds {
|
||||
_va[_i] = fileIds[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, spaceId)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FilesInfo")
|
||||
}
|
||||
|
||||
var r0 []*fileproto.FileInfo
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, ...domain.FileId) ([]*fileproto.FileInfo, error)); ok {
|
||||
return rf(ctx, spaceId, fileIds...)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, ...domain.FileId) []*fileproto.FileInfo); ok {
|
||||
r0 = rf(ctx, spaceId, fileIds...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*fileproto.FileInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, ...domain.FileId) error); ok {
|
||||
r1 = rf(ctx, spaceId, fileIds...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRpcStore_FilesInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FilesInfo'
|
||||
type MockRpcStore_FilesInfo_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// FilesInfo is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - spaceId string
|
||||
// - fileIds ...domain.FileId
|
||||
func (_e *MockRpcStore_Expecter) FilesInfo(ctx interface{}, spaceId interface{}, fileIds ...interface{}) *MockRpcStore_FilesInfo_Call {
|
||||
return &MockRpcStore_FilesInfo_Call{Call: _e.mock.On("FilesInfo",
|
||||
append([]interface{}{ctx, spaceId}, fileIds...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_FilesInfo_Call) Run(run func(ctx context.Context, spaceId string, fileIds ...domain.FileId)) *MockRpcStore_FilesInfo_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]domain.FileId, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(domain.FileId)
|
||||
}
|
||||
}
|
||||
run(args[0].(context.Context), args[1].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_FilesInfo_Call) Return(_a0 []*fileproto.FileInfo, _a1 error) *MockRpcStore_FilesInfo_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_FilesInfo_Call) RunAndReturn(run func(context.Context, string, ...domain.FileId) ([]*fileproto.FileInfo, error)) *MockRpcStore_FilesInfo_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, k
|
||||
func (_m *MockRpcStore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error) {
|
||||
ret := _m.Called(ctx, k)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 blocks.Block
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, cid.Cid) (blocks.Block, error)); ok {
|
||||
return rf(ctx, k)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, cid.Cid) blocks.Block); ok {
|
||||
r0 = rf(ctx, k)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(blocks.Block)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, cid.Cid) error); ok {
|
||||
r1 = rf(ctx, k)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRpcStore_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
|
||||
type MockRpcStore_Get_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Get is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - k cid.Cid
|
||||
func (_e *MockRpcStore_Expecter) Get(ctx interface{}, k interface{}) *MockRpcStore_Get_Call {
|
||||
return &MockRpcStore_Get_Call{Call: _e.mock.On("Get", ctx, k)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Get_Call) Run(run func(ctx context.Context, k cid.Cid)) *MockRpcStore_Get_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(cid.Cid))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Get_Call) Return(_a0 blocks.Block, _a1 error) *MockRpcStore_Get_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_Get_Call) RunAndReturn(run func(context.Context, cid.Cid) (blocks.Block, error)) *MockRpcStore_Get_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetMany provides a mock function with given fields: ctx, ks
|
||||
func (_m *MockRpcStore) GetMany(ctx context.Context, ks []cid.Cid) <-chan blocks.Block {
|
||||
ret := _m.Called(ctx, ks)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetMany")
|
||||
}
|
||||
|
||||
var r0 <-chan blocks.Block
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []cid.Cid) <-chan blocks.Block); ok {
|
||||
r0 = rf(ctx, ks)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(<-chan blocks.Block)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_GetMany_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMany'
|
||||
type MockRpcStore_GetMany_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetMany is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - ks []cid.Cid
|
||||
func (_e *MockRpcStore_Expecter) GetMany(ctx interface{}, ks interface{}) *MockRpcStore_GetMany_Call {
|
||||
return &MockRpcStore_GetMany_Call{Call: _e.mock.On("GetMany", ctx, ks)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_GetMany_Call) Run(run func(ctx context.Context, ks []cid.Cid)) *MockRpcStore_GetMany_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].([]cid.Cid))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_GetMany_Call) Return(_a0 <-chan blocks.Block) *MockRpcStore_GetMany_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_GetMany_Call) RunAndReturn(run func(context.Context, []cid.Cid) <-chan blocks.Block) *MockRpcStore_GetMany_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// IterateFiles provides a mock function with given fields: ctx, iterFunc
|
||||
func (_m *MockRpcStore) IterateFiles(ctx context.Context, iterFunc func(domain.FullFileId)) error {
|
||||
ret := _m.Called(ctx, iterFunc)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IterateFiles")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, func(domain.FullFileId)) error); ok {
|
||||
r0 = rf(ctx, iterFunc)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRpcStore_IterateFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IterateFiles'
|
||||
type MockRpcStore_IterateFiles_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// IterateFiles is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - iterFunc func(domain.FullFileId)
|
||||
func (_e *MockRpcStore_Expecter) IterateFiles(ctx interface{}, iterFunc interface{}) *MockRpcStore_IterateFiles_Call {
|
||||
return &MockRpcStore_IterateFiles_Call{Call: _e.mock.On("IterateFiles", ctx, iterFunc)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_IterateFiles_Call) Run(run func(ctx context.Context, iterFunc func(domain.FullFileId))) *MockRpcStore_IterateFiles_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(func(domain.FullFileId)))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_IterateFiles_Call) Return(_a0 error) *MockRpcStore_IterateFiles_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_IterateFiles_Call) RunAndReturn(run func(context.Context, func(domain.FullFileId)) error) *MockRpcStore_IterateFiles_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SpaceInfo provides a mock function with given fields: ctx, spaceId
|
||||
func (_m *MockRpcStore) SpaceInfo(ctx context.Context, spaceId string) (*fileproto.SpaceInfoResponse, error) {
|
||||
ret := _m.Called(ctx, spaceId)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for SpaceInfo")
|
||||
}
|
||||
|
||||
var r0 *fileproto.SpaceInfoResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (*fileproto.SpaceInfoResponse, error)); ok {
|
||||
return rf(ctx, spaceId)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) *fileproto.SpaceInfoResponse); ok {
|
||||
r0 = rf(ctx, spaceId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*fileproto.SpaceInfoResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, spaceId)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRpcStore_SpaceInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SpaceInfo'
|
||||
type MockRpcStore_SpaceInfo_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// SpaceInfo is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - spaceId string
|
||||
func (_e *MockRpcStore_Expecter) SpaceInfo(ctx interface{}, spaceId interface{}) *MockRpcStore_SpaceInfo_Call {
|
||||
return &MockRpcStore_SpaceInfo_Call{Call: _e.mock.On("SpaceInfo", ctx, spaceId)}
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_SpaceInfo_Call) Run(run func(ctx context.Context, spaceId string)) *MockRpcStore_SpaceInfo_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_SpaceInfo_Call) Return(info *fileproto.SpaceInfoResponse, err error) *MockRpcStore_SpaceInfo_Call {
|
||||
_c.Call.Return(info, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRpcStore_SpaceInfo_Call) RunAndReturn(run func(context.Context, string) (*fileproto.SpaceInfoResponse, error)) *MockRpcStore_SpaceInfo_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockRpcStore creates a new instance of MockRpcStore. 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 NewMockRpcStore(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockRpcStore {
|
||||
mock := &MockRpcStore{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
|
@ -10,8 +10,6 @@ import (
|
|||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
spacecore "github.com/anyproto/anytype-heart/space/spacecore"
|
||||
|
||||
streampool "github.com/anyproto/any-sync/net/streampool"
|
||||
)
|
||||
|
||||
// MockSpaceCoreService is an autogenerated mock type for the SpaceCoreService type
|
||||
|
@ -598,53 +596,6 @@ func (_c *MockSpaceCoreService_Run_Call) RunAndReturn(run func(context.Context)
|
|||
return _c
|
||||
}
|
||||
|
||||
// StreamPool provides a mock function with given fields:
|
||||
func (_m *MockSpaceCoreService) StreamPool() streampool.StreamPool {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for StreamPool")
|
||||
}
|
||||
|
||||
var r0 streampool.StreamPool
|
||||
if rf, ok := ret.Get(0).(func() streampool.StreamPool); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(streampool.StreamPool)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockSpaceCoreService_StreamPool_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StreamPool'
|
||||
type MockSpaceCoreService_StreamPool_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// StreamPool is a helper method to define mock.On call
|
||||
func (_e *MockSpaceCoreService_Expecter) StreamPool() *MockSpaceCoreService_StreamPool_Call {
|
||||
return &MockSpaceCoreService_StreamPool_Call{Call: _e.mock.On("StreamPool")}
|
||||
}
|
||||
|
||||
func (_c *MockSpaceCoreService_StreamPool_Call) Run(run func()) *MockSpaceCoreService_StreamPool_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSpaceCoreService_StreamPool_Call) Return(_a0 streampool.StreamPool) *MockSpaceCoreService_StreamPool_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSpaceCoreService_StreamPool_Call) RunAndReturn(run func() streampool.StreamPool) *MockSpaceCoreService_StreamPool_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockSpaceCoreService creates a new instance of MockSpaceCoreService. 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 NewMockSpaceCoreService(t interface {
|
||||
|
|
|
@ -62,7 +62,6 @@ type SpaceCoreService interface {
|
|||
Pick(ctx context.Context, id string) (*AnySpace, error)
|
||||
CloseSpace(ctx context.Context, id string) error
|
||||
|
||||
StreamPool() streampool.StreamPool
|
||||
app.ComponentRunnable
|
||||
}
|
||||
|
||||
|
@ -99,6 +98,7 @@ func (s *service) Init(a *app.App) (err error) {
|
|||
s.spaceStorageProvider = a.MustComponent(spacestorage.CName).(storage.ClientStorage)
|
||||
s.peerStore = a.MustComponent(peerstore.CName).(peerstore.PeerStore)
|
||||
s.peerService = a.MustComponent(peerservice.CName).(peerservice.PeerService)
|
||||
s.streamPool = a.MustComponent(streampool.CName).(streampool.StreamPool)
|
||||
s.syncStatusService = app.MustComponent[syncStatusService](a)
|
||||
localDiscovery := a.MustComponent(localdiscovery.CName).(localdiscovery.LocalDiscovery)
|
||||
localDiscovery.SetNotifier(s)
|
||||
|
@ -196,10 +196,6 @@ func (s *service) Pick(ctx context.Context, id string) (space *AnySpace, err err
|
|||
return v.(*AnySpace), nil
|
||||
}
|
||||
|
||||
func (s *service) StreamPool() streampool.StreamPool {
|
||||
return s.streamPool
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, spaceID string) (err error) {
|
||||
networkID := s.nodeConf.Configuration().NetworkId
|
||||
delConf, err := coordinatorproto.PrepareDeleteConfirmation(s.accountKeys.SignKey, spaceID, s.accountKeys.PeerId, networkID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue