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

GO-4969: Mock ExportMarkdown in tests for GetObject, CreateObject, and GetTemplate

This commit is contained in:
Jannis Metrikat 2025-05-06 18:01:23 +02:00
parent 9ae5cc1243
commit 62cd6b7eda
No known key found for this signature in database
GPG key ID: B223CAC5AAF85615
3 changed files with 19 additions and 3 deletions

View file

@ -500,6 +500,11 @@ func TestObjectService_GetObject(t *testing.T) {
Records: []*types.Struct{},
}, nil).Once()
// Mock ExportMarkdown
fx.exportService.
On("ExportSingleInMemory", mock.Anything, mockedSpaceId, mockedObjectId, model.Export_Markdown).
Return("dummy markdown", nil).Once()
// when
object, err := fx.service.GetObject(ctx, mockedSpaceId, mockedObjectId)
@ -645,6 +650,11 @@ func TestObjectService_CreateObject(t *testing.T) {
Error: &pb.RpcObjectSearchResponseError{Code: pb.RpcObjectSearchResponseError_NULL},
}).Times(3)
// Mock ExportMarkdown
fx.exportService.
On("ExportSingleInMemory", mock.Anything, mockedSpaceId, mockedNewObjectId, model.Export_Markdown).
Return("dummy markdown", nil).Once()
// when
object, err := fx.service.CreateObject(ctx, mockedSpaceId, apimodel.CreateObjectRequest{
Name: mockedObjectName,

View file

@ -36,10 +36,11 @@ type fixture struct {
func newFixture(t *testing.T) *fixture {
mwMock := mock_apicore.NewMockClientCommands(t)
exportMock := mock_apicore.NewMockExportService(t)
objectService := NewService(mwMock, exportMock, gatewayUrl, techSpaceId)
service := NewService(mwMock, exportMock, gatewayUrl, techSpaceId)
return &fixture{
service: objectService,
mwMock: mwMock,
service: service,
mwMock: mwMock,
exportService: exportMock,
}
}

View file

@ -127,6 +127,11 @@ func TestObjectService_GetTemplate(t *testing.T) {
Error: &pb.RpcObjectSearchResponseError{Code: pb.RpcObjectSearchResponseError_NULL},
}).Times(3)
// Mock ExportMarkdown
fx.exportService.
On("ExportSingleInMemory", mock.Anything, mockedSpaceId, mockedTemplateId, model.Export_Markdown).
Return("dummy markdown", nil).Once()
// when
template, err := fx.service.GetTemplate(ctx, mockedSpaceId, mockedTypeId, mockedTemplateId)