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

GO-2078: add test

Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
This commit is contained in:
AnastasiaShemyakinskaya 2024-10-07 11:51:57 +02:00
parent 7310fbf053
commit dbf9c3b212
No known key found for this signature in database
GPG key ID: CCD60ED83B103281

View file

@ -0,0 +1,35 @@
//go:build !rasterizesvg
package svg
import (
"bytes"
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/anyproto/anytype-heart/core/files/mock_files"
"github.com/anyproto/anytype-heart/pkg/lib/pb/storage"
)
func TestProcessSvg(t *testing.T) {
t.Run("process svg successful", func(t *testing.T) {
// given
svgContent := []byte(`<svg viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>`)
file := mock_files.NewMockFile(t)
file.EXPECT().Reader(context.Background()).Return(bytes.NewReader(svgContent), nil)
fileInfo := &storage.FileInfo{}
file.EXPECT().Info().Return(fileInfo)
// when
result, err := ProcessSvg(context.Background(), file)
// then
assert.NoError(t, err)
assert.NotNil(t, result)
assert.Equal(t, svgMedia, fileInfo.Media)
})
}