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

GO-2043: fix tests

Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
This commit is contained in:
AnastasiaShemyakinskaya 2024-08-09 12:58:08 +02:00
parent 49a760418a
commit 10f049e6a1
No known key found for this signature in database
GPG key ID: CCD60ED83B103281
3 changed files with 44 additions and 28 deletions

View file

@ -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) {

View file

@ -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 &notificationProcess{progress: &progress{
id: bson.NewObjectId().Hex(),
done: make(chan struct{}),

View file

@ -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 {