forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pdfengines_test.go
37 lines (32 loc) · 992 Bytes
/
pdfengines_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
package gotenberg
import (
"context"
"fmt"
"net/http"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/runatal/gotenberg-go-client/v8/document"
"github.com/runatal/gotenberg-go-client/v8/test"
)
func TestMerge(t *testing.T) {
c, err := NewClient("http://localhost:3000", &http.Client{})
require.NoError(t, err)
pdf1, err := document.FromPath("gotenberg1.pdf", test.PDFTestFilePath(t, "gotenberg.pdf"))
require.NoError(t, err)
pdf2, err := document.FromPath("gotenberg2.pdf", test.PDFTestFilePath(t, "gotenberg.pdf"))
require.NoError(t, err)
req := NewMergeRequest(pdf1, pdf2)
req.Trace("testMerge")
req.UseBasicAuth("foo", "bar")
req.OutputFilename("foo.pdf")
dirPath, err := test.Rand()
require.NoError(t, err)
dest := fmt.Sprintf("%s/foo.pdf", dirPath)
err = c.Store(context.Background(), req, dest)
require.NoError(t, err)
assert.FileExists(t, dest)
err = os.RemoveAll(dirPath)
require.NoError(t, err)
}