-
Notifications
You must be signed in to change notification settings - Fork 37
/
api_drive_spaces_test.go
150 lines (125 loc) · 4.31 KB
/
api_drive_spaces_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Copyright 2020 zhaoyunxing.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dingtalk
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zhaoyunxing92/dingtalk/v2/constant/file"
"github.com/zhaoyunxing92/dingtalk/v2/constant/policy"
"github.com/zhaoyunxing92/dingtalk/v2/constant/spaces"
"github.com/zhaoyunxing92/dingtalk/v2/request"
)
func TestDingTalk_CreateDriveSpaces(t *testing.T) {
t.Skip()
res, err := client.CreateDriveSpaces("golang", "ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
}
func TestDingTalk_DeleteDriveSpaces(t *testing.T) {
t.Skip()
res, err := client.DeleteDriveSpaces("5296669223", "ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
}
func TestDingTalk_GetDriveSpaces(t *testing.T) {
res, err := client.GetDriveSpaces("ABNiSWeAolg5OETyYT60wdQiEiE", spaces.Org, "", 5)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, len(res.Spaces), 1)
}
func TestDingTalk_GetDriveSpacesInfo(t *testing.T) {
res, err := client.GetDriveSpacesInfo("3452011774", "ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.Name, "全员文件夹")
assert.Equal(t, res.PermissionMode, "acl")
assert.Equal(t, res.Type, string(spaces.Org))
}
func TestDingTalk_GetDriveSpacesFiles(t *testing.T) {
files := request.NewGetDriveSpacesFiles("3452011774", "ABNiSWeAolg5OETyYT60wdQiEiE", 10).
Build()
res, err := client.GetDriveSpacesFiles(files)
assert.Nil(t, err)
assert.NotNil(t, res)
}
func TestDingTalk_GetDriveSpacesFileInfo(t *testing.T) {
res, err := client.GetDriveSpacesFileInfo("3452011774", "47453824236",
"ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.FileExtension, "pdf")
}
func TestDingTalk_CreateDriveSpacesFiles_Folder(t *testing.T) {
f := request.NewCreateDriveSpacesFiles("ABNiSWeAolg5OETyYT60wdQiEiE", "3452011774",
"dingtalk", file.Folder).
SetConflictPolicy(policy.Overwrite).
Build()
res, err := client.CreateDriveSpacesFiles(f)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.FileName, "dingtalk")
}
func TestDingTalk_CreateDriveSpacesFiles_File(t *testing.T) {
t.Skip()
f := request.NewCreateDriveSpacesFiles("ABNiSWeAolg5OETyYT60wdQiEiE", "3452011774",
"dingtalk.png", file.File).
SetMediaId("@lALPDeREWzc3zXBgzQJA").
SetConflictPolicy(policy.Overwrite).
Build()
res, err := client.CreateDriveSpacesFiles(f)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.FileName, "golang")
}
func TestDingTalk_DeleteDriveSpacesFiles(t *testing.T) {
t.Skip()
res, err := client.DeleteDriveSpacesFiles("3452011774", "47459660818",
"ABNiSWeAolg5OETyYT60wdQiEiE", policy.Completely)
assert.Nil(t, err)
assert.NotNil(t, res)
}
func TestDingTalk_MoveDriveSpacesFiles(t *testing.T) {
t.Skip()
files := request.NewMoveDriveSpacesFiles("3452011774", "47494266429",
"47494327156", "ABNiSWeAolg5OETyYT60wdQiEiE").
SetTargetParentId("3452011774").
SetConflictPolicy(policy.Overwrite).
Build()
res, err := client.MoveDriveSpacesFiles(files)
assert.Nil(t, err)
assert.NotNil(t, res)
}
func TestDingTalk_RenameDriveSpacesFiles(t *testing.T) {
t.Skip()
res, err := client.RenameDriveSpacesFiles("3452011774", "47494266429",
"newName", "ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.FileName, "newName")
}
func TestDingTalk_GetDriveSpacesFilesDownloadInfo(t *testing.T) {
t.Skip()
res, err := client.GetDriveSpacesFilesDownloadInfo("3452011774", "47494266429",
"ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
}
func TestDingTalk_GetDriveSpacesFilesPermissions(t *testing.T) {
res, err := client.GetDriveSpacesFilesPermissions("3452011774", "47494266429",
"ABNiSWeAolg5OETyYT60wdQiEiE")
assert.Nil(t, err)
assert.NotNil(t, res)
}