From 10f049e6a137718791dc8684ba08d92587c17094 Mon Sep 17 00:00:00 2001 From: AnastasiaShemyakinskaya Date: Fri, 9 Aug 2024 12:58:08 +0200 Subject: [PATCH] GO-2043: fix tests Signed-off-by: AnastasiaShemyakinskaya --- core/block/import/importer_test.go | 3 +- core/block/process/notificationprocess.go | 9 ++-- tests/integration/import_test.go | 60 ++++++++++++++--------- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/core/block/import/importer_test.go b/core/block/import/importer_test.go index 8780de605..de321cd7f 100644 --- a/core/block/import/importer_test.go +++ b/core/block/import/importer_test.go @@ -341,7 +341,8 @@ func Test_ImportExternalPlugin(t *testing.T) { true, } res := i.Import(context.Background(), importRequest) - assert.Nil(t, res) + assert.NotNil(t, res) + assert.Nil(t, res.Err) } func Test_ImportExternalPluginError(t *testing.T) { diff --git a/core/block/process/notificationprocess.go b/core/block/process/notificationprocess.go index 026f08c4b..434bb70f3 100644 --- a/core/block/process/notificationprocess.go +++ b/core/block/process/notificationprocess.go @@ -3,7 +3,6 @@ package process import ( "github.com/globalsign/mgo/bson" - "github.com/anyproto/anytype-heart/core/notifications" "github.com/anyproto/anytype-heart/pb" "github.com/anyproto/anytype-heart/pkg/lib/logging" "github.com/anyproto/anytype-heart/pkg/lib/pb/model" @@ -11,6 +10,10 @@ import ( var log = logging.Logger("notification-process") +type NotificationService interface { + CreateAndSend(notification *model.Notification) error +} + type NotificationSender interface { SendNotification() } @@ -23,10 +26,10 @@ type Notificationable interface { type notificationProcess struct { *progress notification *model.Notification - notificationService notifications.Notifications + notificationService NotificationService } -func NewNotificationProcess(pbType pb.ModelProcessType, notificationService notifications.Notifications) Notificationable { +func NewNotificationProcess(pbType pb.ModelProcessType, notificationService NotificationService) Notificationable { return ¬ificationProcess{progress: &progress{ id: bson.NewObjectId().Hex(), done: make(chan struct{}), diff --git a/tests/integration/import_test.go b/tests/integration/import_test.go index 9b44f1088..c76962c82 100644 --- a/tests/integration/import_test.go +++ b/tests/integration/import_test.go @@ -32,16 +32,20 @@ func TestImportFileFromRelation(t *testing.T) { }) importerService := getService[importer.Importer](app) - res := importerService.Import(ctx, &pb.RpcObjectImportRequest{ - SpaceId: app.personalSpaceId(), - Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS, - Type: model.Import_Pb, - Params: &pb.RpcObjectImportRequestParamsOfPbParams{ - PbParams: &pb.RpcObjectImportRequestPbParams{ - Path: []string{"./testdata/import/object with file relation/"}, + res := importerService.Import(ctx, &importer.ImportRequest{ + RpcObjectImportRequest: &pb.RpcObjectImportRequest{ + SpaceId: app.personalSpaceId(), + Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS, + Type: model.Import_Pb, + Params: &pb.RpcObjectImportRequestParamsOfPbParams{ + PbParams: &pb.RpcObjectImportRequestPbParams{ + Path: []string{"./testdata/import/object with file relation/"}, + }, }, }, - }, objectorigin.Import(model.Import_Pb), nil) + Origin: objectorigin.Import(model.Import_Pb), + IsSync: true, + }) require.NoError(t, res.Err) app.waitEventMessage(t, func(msg *pb.EventMessage) bool { @@ -87,16 +91,20 @@ func testImportFileFromMarkdown(t *testing.T, path string) { }) importerService := getService[importer.Importer](app) - res := importerService.Import(ctx, &pb.RpcObjectImportRequest{ - SpaceId: app.personalSpaceId(), - Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS, - Type: model.Import_Markdown, - Params: &pb.RpcObjectImportRequestParamsOfMarkdownParams{ - MarkdownParams: &pb.RpcObjectImportRequestMarkdownParams{ - Path: []string{path}, + res := importerService.Import(ctx, &importer.ImportRequest{ + RpcObjectImportRequest: &pb.RpcObjectImportRequest{ + SpaceId: app.personalSpaceId(), + Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS, + Type: model.Import_Markdown, + Params: &pb.RpcObjectImportRequestParamsOfMarkdownParams{ + MarkdownParams: &pb.RpcObjectImportRequestMarkdownParams{ + Path: []string{path}, + }, }, }, - }, objectorigin.Import(model.Import_Markdown), nil) + Origin: objectorigin.Import(model.Import_Markdown), + IsSync: true, + }) require.NoError(t, res.Err) app.waitEventMessage(t, func(msg *pb.EventMessage) bool { @@ -124,16 +132,20 @@ func testImportObjectWithFileBlock(t *testing.T, path string) { }) importerService := getService[importer.Importer](app) - res := importerService.Import(ctx, &pb.RpcObjectImportRequest{ - SpaceId: app.personalSpaceId(), - Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS, - Type: model.Import_Pb, - Params: &pb.RpcObjectImportRequestParamsOfPbParams{ - PbParams: &pb.RpcObjectImportRequestPbParams{ - Path: []string{path}, + res := importerService.Import(ctx, &importer.ImportRequest{ + RpcObjectImportRequest: &pb.RpcObjectImportRequest{ + SpaceId: app.personalSpaceId(), + Mode: pb.RpcObjectImportRequest_IGNORE_ERRORS, + Type: model.Import_Pb, + Params: &pb.RpcObjectImportRequestParamsOfPbParams{ + PbParams: &pb.RpcObjectImportRequestPbParams{ + Path: []string{path}, + }, }, }, - }, objectorigin.Import(model.Import_Pb), nil) + Origin: objectorigin.Import(model.Import_Pb), + IsSync: true, + }) require.NoError(t, res.Err) app.waitEventMessage(t, func(msg *pb.EventMessage) bool {