forked from ConvertAPI/convertapi-library-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_test.go
49 lines (37 loc) · 1.06 KB
/
convert_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
47
48
49
package convertapi
import (
"github.com/ConvertAPI/convertapi-go/config"
"github.com/ConvertAPI/convertapi-go/param"
"github.com/stretchr/testify/assert"
"os"
"path"
"testing"
)
func TestSetup(t *testing.T) {
config.Default.Secret = os.Getenv("CONVERTAPI_SECRET")
assert.Equal(t, config.Default.Secret, os.Getenv("CONVERTAPI_SECRET"))
}
func TestConvertPath(t *testing.T) {
file, errs := ConvertPath("assets/test.docx", path.Join(os.TempDir(), "convertapi-test.pdf"))
assert.Nil(t, errs)
assert.NotEmpty(t, file.Name())
}
func TestChained(t *testing.T) {
jpgRes := Convert("docx", "jpg", []param.IParam{
param.NewPath("file", "assets/test.docx", nil),
}, nil)
zipRes := Convert("jpg", "zip", []param.IParam{
param.NewResult("files", jpgRes, nil),
}, nil)
zipCost, err := zipRes.Cost()
assert.Nil(t, err)
assert.NotEmpty(t, zipCost)
files, err := zipRes.Files()
assert.Nil(t, err)
assert.Equal(t, "test.zip", files[0].FileName)
}
func TestUserInfo(t *testing.T) {
user, err := UserInfo(nil)
assert.Nil(t, err)
assert.NotEmpty(t, user.SecondsLeft)
}