forked from star-table/dingtalk-sdk-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_cspace_caller_test.go
81 lines (64 loc) · 1.91 KB
/
api_cspace_caller_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package sdk
import (
"github.com/polaris-team/dingtalk-sdk-golang/encrypt"
"github.com/polaris-team/dingtalk-sdk-golang/file"
"github.com/polaris-team/dingtalk-sdk-golang/json"
"os"
"testing"
"time"
)
func TestDingTalkClient_FileUploadSingle(t *testing.T) {
resp, _ := CreateClient().FileUploadSingle("C:\\Users\\admin\\Desktop\\dingding-test.jpg")
t.Log(json.ToJson(resp))
}
func TestDingTalkClient_SendDingPanFileToSingleChat(t *testing.T) {
client := CreateClient()
mediaId := "#iAEHAqRmaWxlA6h5dW5kaXNrMATOCw_n8wXNBvQGzWSTB85dIrQTCM0iXw"
filename := "test.jpg"
resp, _ := client.SendDingPanFileToSingleChat("15001956402427783", encrypt.URLEncode(mediaId), encrypt.URLEncode(filename))
t.Log(json.ToJson(resp))
}
func TestDingTalkClient_AddFileToUserCSpace(t *testing.T) {
//TODO
}
func TestDingTalkClient_GetCustomSpace(t *testing.T) {
resp, err := CreateClient().GetCustomSpace("test")
t.Log(json.ToJson(resp))
t.Log(err)
}
func TestDingTalkClient_GrantCustomSpace(t *testing.T) {
//TODO
}
func TestDingTalkClient_UploadTransaction(t *testing.T) {
//TODO
//path := "D:\\download\\easyscheduler-EasyScheduler-dev.zip"
path := "D:\\download\\20190528151901.png"
count := 1
fileInfo, err := os.Stat(path)
if err != nil {
t.Log(err)
}
client := CreateClient()
fileSize := fileInfo.Size()
beginTrans, err := client.BeginUploadTransaction(fileSize, count)
if err != nil {
t.Log(err)
}
t.Log(json.ToJson(beginTrans))
uploadId := encrypt.URLEncode(beginTrans.UploadId)
time.Sleep(time.Duration(2) * time.Second)
buf, err := file.GetFileReader(path)
if err != nil {
t.Log(err)
}
for i := 1; i <= count; i++ {
uploadChunkResp, err := client.BeginUploadChunk(uploadId, i, buf)
if err != nil {
t.Log(err)
}
t.Log(json.ToJson(uploadChunkResp))
time.Sleep(time.Duration(2) * time.Second)
}
resp, _ := client.CommitUploadTransaction(fileSize, count, uploadId)
t.Log(json.ToJson(resp))
}