diff --git a/common/commonspace/diffservice/diffsyncer.go b/common/commonspace/diffservice/diffsyncer.go index 88cd00f4..8e354294 100644 --- a/common/commonspace/diffservice/diffsyncer.go +++ b/common/commonspace/diffservice/diffsyncer.go @@ -27,12 +27,13 @@ func newDiffSyncer( clientFactory spacesyncproto.ClientFactory, log *zap.Logger) DiffSyncer { return &diffSyncer{ - diff: diff, - nconf: nconf, - spaceId: spaceId, - cache: cache, - storage: storage, - log: log, + diff: diff, + nconf: nconf, + spaceId: spaceId, + cache: cache, + storage: storage, + clientFactory: clientFactory, + log: log, } } diff --git a/common/commonspace/diffservice/diffsyncer_test.go b/common/commonspace/diffservice/diffsyncer_test.go index af199c54..ffc610c8 100644 --- a/common/commonspace/diffservice/diffsyncer_test.go +++ b/common/commonspace/diffservice/diffsyncer_test.go @@ -4,8 +4,10 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" "github.com/golang/mock/gomock" @@ -30,5 +32,20 @@ func TestDiffSyncer_Sync(t *testing.T) { spaceId := "spaceId" l := logger.NewNamed(spaceId) diffSyncer := newDiffSyncer(spaceId, diffMock, nconfMock, cacheMock, stMock, factory, l) - diffSyncer.Sync(ctx) + + t.Run("diff syncer sync simple", func(t *testing.T) { + nconfMock.EXPECT(). + ResponsiblePeers(gomock.Any(), spaceId). + Return([]peer.Peer{nil}, nil) + diffMock.EXPECT(). + Diff(gomock.Any(), gomock.Eq(remotediff.NewRemoteDiff(spaceId, clientMock))). + Return([]string{"new"}, []string{"changed"}, nil, nil) + cacheMock.EXPECT(). + GetTree(gomock.Any(), spaceId, "new"). + Return(cache.TreeResult{}, nil) + cacheMock.EXPECT(). + GetTree(gomock.Any(), spaceId, "changed"). + Return(cache.TreeResult{}, nil) + _ = diffSyncer.Sync(ctx) + }) }