-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_document_test.go
46 lines (38 loc) · 1.08 KB
/
api_document_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
42
43
44
45
46
package squeeze_go_client
import (
"github.com/dexpro-solutions-gmbh/squeeze-go-client/internal"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestDocumentApi_ProcessDocument(t *testing.T) {
c := NewClient(internal.GetEnvVal("SQZ_BASE_PATH"))
c.ApiKey = internal.GetEnvApiKey(t)
filepath := "testdata/brt.pdf"
filename := "brt.pdf"
if _, err := os.Stat(filepath); err != nil {
if os.IsNotExist(err) {
// As long as we do not version testdata in this git repository, we skip this test in the CI
t.Skip("Test file not found: " + filepath)
} else {
t.Error(err)
}
}
file, err := os.Open(filepath)
if err != nil {
t.Error(err)
}
defer file.Close()
classes, e := c.Document.ProcessDocument(1, 0, "", nil, file, filename)
assert.Nil(t, e)
assert.NotNil(t, classes)
assert.NotEmpty(t, classes)
}
func TestDocumentApi_GetDocumentById(t *testing.T) {
c := NewClient(internal.GetEnvVal("SQZ_BASE_PATH"))
c.ApiKey = internal.GetEnvApiKey(t)
classes, e := c.Document.GetDocumentById(1)
assert.Nil(t, e)
assert.NotNil(t, classes)
assert.NotEmpty(t, classes)
}