forked from jerbob92/ghostscript-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessor_test.go
41 lines (32 loc) · 964 Bytes
/
processor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package ghostscript
import (
"bytes"
"context"
_ "embed"
"testing"
"github.com/redpanda-data/benthos/v4/public/service"
"github.com/stretchr/testify/require"
)
var (
//go:embed testdata/index.pdf
pdfOne []byte
//go:embed testdata/invoicesample.pdf
pdfTwo []byte
)
func TestGhostscriptProcessor(t *testing.T) {
proc, err := newGhostscriptProcessor()
require.NoError(t, err)
result, err := proc.Process(context.Background(), service.NewMessage(pdfOne))
require.NoError(t, err)
require.Len(t, result, 1)
jpgOne, err := result[0].AsBytes()
require.NoError(t, err)
require.True(t, bytes.HasPrefix(jpgOne, []byte{0xff, 0xd8, 0xff, 0xe0}))
result, err = proc.Process(context.Background(), service.NewMessage(pdfTwo))
require.NoError(t, err)
require.Len(t, result, 1)
jpgTwo, err := result[0].AsBytes()
require.NoError(t, err)
require.True(t, bytes.HasPrefix(jpgTwo, []byte{0xff, 0xd8, 0xff, 0xe0}))
require.NotEqual(t, jpgOne, jpgTwo)
}