forked from mingcheng/aliyundrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_test.go
42 lines (35 loc) · 918 Bytes
/
get_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
package aliyundrive
import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)
func TestAliyunDrive_Get(t *testing.T) {
cli := NewDrive(t)
assert.NotNil(t, cli)
self, err := cli.MySelf(context.TODO())
assert.NoError(t, err)
assert.NotNil(t, self)
assert.NotEmpty(t, self.UserID)
result, err := cli.UploadFile(context.TODO(), &UploadFileReq{
DriveID: self.DefaultDriveID,
ParentID: RootFileID,
FilePath: "/etc/hosts",
CheckNameMode: ModeAutoRename,
})
assert.NoError(t, err)
assert.NotNil(t, result)
assert.NotEmpty(t, result.FileID)
info, err := cli.Get(context.TODO(), &GetFileReq{
DriveID: self.DefaultDriveID,
FileID: result.FileID,
})
assert.NoError(t, err)
assert.NotNil(t, info)
assert.NotEmpty(t, info.FileID)
err = cli.Trash(context.TODO(), &DeleteFileReq{
DriveID: self.DefaultDriveID,
FileID: result.FileID,
})
assert.NoError(t, err)
}