Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hexbee
Cloudreve
提交
79daf928
C
Cloudreve
项目概览
hexbee
/
Cloudreve
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cloudreve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
79daf928
编写于
5月 01, 2020
作者:
H
HFO4
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test: List files in OneDrive
上级
8a2be58e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
133 addition
and
1 deletion
+133
-1
assets
assets
+1
-1
pkg/filesystem/driver/onedrive/api_test.go
pkg/filesystem/driver/onedrive/api_test.go
+60
-0
pkg/filesystem/driver/onedrive/handler_test.go
pkg/filesystem/driver/onedrive/handler_test.go
+72
-0
未找到文件。
assets
@
1b9186c3
比较
d752e266
...
1b9186c3
Subproject commit
d752e266d52230b3334b88b22facd9f5d37eda9e
Subproject commit
1b9186c3c7aab6a619fc7e872ada9f65ca08a34a
pkg/filesystem/driver/onedrive/api_test.go
浏览文件 @
79daf928
...
...
@@ -752,6 +752,66 @@ func TestClient_Delete(t *testing.T) {
}
}
func
TestClient_ListChildren
(
t
*
testing
.
T
)
{
asserts
:=
assert
.
New
(
t
)
client
,
_
:=
NewClient
(
&
model
.
Policy
{})
client
.
Credential
.
AccessToken
=
"AccessToken"
// 根目录,请求失败,重测试
{
client
.
Credential
.
ExpiresIn
=
0
res
,
err
:=
client
.
ListChildren
(
context
.
Background
(),
"/"
)
asserts
.
Error
(
err
)
asserts
.
Empty
(
res
)
}
// 非根目录,未知响应
{
client
.
Credential
.
ExpiresIn
=
time
.
Now
()
.
Add
(
time
.
Duration
(
100
)
*
time
.
Hour
)
.
Unix
()
clientMock
:=
ClientMock
{}
clientMock
.
On
(
"Request"
,
"GET"
,
testMock
.
Anything
,
testMock
.
Anything
,
testMock
.
Anything
,
)
.
Return
(
&
request
.
Response
{
Err
:
nil
,
Response
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
ioutil
.
NopCloser
(
strings
.
NewReader
(
`???`
)),
},
})
client
.
Request
=
clientMock
res
,
err
:=
client
.
ListChildren
(
context
.
Background
(),
"/uploads"
)
asserts
.
Error
(
err
)
asserts
.
Empty
(
res
)
}
// 非根目录,成功
{
client
.
Credential
.
ExpiresIn
=
time
.
Now
()
.
Add
(
time
.
Duration
(
100
)
*
time
.
Hour
)
.
Unix
()
clientMock
:=
ClientMock
{}
clientMock
.
On
(
"Request"
,
"GET"
,
testMock
.
Anything
,
testMock
.
Anything
,
testMock
.
Anything
,
)
.
Return
(
&
request
.
Response
{
Err
:
nil
,
Response
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
ioutil
.
NopCloser
(
strings
.
NewReader
(
`{"value":[{}]}`
)),
},
})
client
.
Request
=
clientMock
res
,
err
:=
client
.
ListChildren
(
context
.
Background
(),
"/uploads"
)
asserts
.
NoError
(
err
)
asserts
.
Len
(
res
,
1
)
}
}
func
TestClient_GetThumbURL
(
t
*
testing
.
T
)
{
asserts
:=
assert
.
New
(
t
)
client
,
_
:=
NewClient
(
&
model
.
Policy
{})
...
...
pkg/filesystem/driver/onedrive/handler_test.go
浏览文件 @
79daf928
...
...
@@ -174,6 +174,78 @@ func TestDriver_Source(t *testing.T) {
}
}
func
TestDriver_List
(
t
*
testing
.
T
)
{
asserts
:=
assert
.
New
(
t
)
handler
:=
Driver
{
Policy
:
&
model
.
Policy
{
AccessKey
:
"ak"
,
SecretKey
:
"sk"
,
BucketName
:
"test"
,
Server
:
"test.com"
,
},
}
handler
.
Client
,
_
=
NewClient
(
&
model
.
Policy
{})
handler
.
Client
.
Credential
.
AccessToken
=
"AccessToken"
handler
.
Client
.
Credential
.
ExpiresIn
=
time
.
Now
()
.
Add
(
time
.
Duration
(
100
)
*
time
.
Hour
)
.
Unix
()
// 非递归
{
clientMock
:=
ClientMock
{}
clientMock
.
On
(
"Request"
,
"GET"
,
testMock
.
Anything
,
testMock
.
Anything
,
testMock
.
Anything
,
)
.
Return
(
&
request
.
Response
{
Err
:
nil
,
Response
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
ioutil
.
NopCloser
(
strings
.
NewReader
(
`{"value":[{}]}`
)),
},
})
handler
.
Client
.
Request
=
clientMock
res
,
err
:=
handler
.
List
(
context
.
Background
(),
"/"
,
false
)
asserts
.
NoError
(
err
)
asserts
.
Len
(
res
,
1
)
}
// 递归一次
{
clientMock
:=
ClientMock
{}
clientMock
.
On
(
"Request"
,
"GET"
,
"me/drive/root/children?$top=999999999"
,
testMock
.
Anything
,
testMock
.
Anything
,
)
.
Return
(
&
request
.
Response
{
Err
:
nil
,
Response
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
ioutil
.
NopCloser
(
strings
.
NewReader
(
`{"value":[{"name":"1","folder":{}}]}`
)),
},
})
clientMock
.
On
(
"Request"
,
"GET"
,
"me/drive/root:/1:/children?$top=999999999"
,
testMock
.
Anything
,
testMock
.
Anything
,
)
.
Return
(
&
request
.
Response
{
Err
:
nil
,
Response
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
ioutil
.
NopCloser
(
strings
.
NewReader
(
`{"value":[{"name":"2"}]}`
)),
},
})
handler
.
Client
.
Request
=
clientMock
res
,
err
:=
handler
.
List
(
context
.
Background
(),
"/"
,
true
)
asserts
.
NoError
(
err
)
asserts
.
Len
(
res
,
2
)
}
}
func
TestDriver_Thumb
(
t
*
testing
.
T
)
{
asserts
:=
assert
.
New
(
t
)
handler
:=
Driver
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录