forked from go-lark/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_upload_test.go
43 lines (37 loc) · 903 Bytes
/
api_upload_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
package lark
import (
"image/jpeg"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUploadImage(t *testing.T) {
resp, err := bot.UploadImage("./fixtures/test.jpg")
if assert.NoError(t, err) {
assert.Zero(t, resp.Code)
t.Log(resp.Data.ImageKey)
assert.NotEmpty(t, resp.Data.ImageKey)
}
}
func TestUploadImageObject(t *testing.T) {
file, _ := os.Open("./fixtures/test.jpg")
img, _ := jpeg.Decode(file)
resp, err := bot.UploadImageObject(img)
if assert.NoError(t, err) {
assert.Zero(t, resp.Code)
t.Log(resp.Data.ImageKey)
assert.NotEmpty(t, resp.Data.ImageKey)
}
}
func TestUploadFile(t *testing.T) {
resp, err := bot.UploadFile(UploadFileRequest{
FileType: "pdf",
FileName: "hello.pdf",
Path: "./fixtures/test.pdf",
})
if assert.NoError(t, err) {
assert.Zero(t, resp.Code)
t.Log(resp.Data.FileKey)
assert.NotEmpty(t, resp.Data.FileKey)
}
}