This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
forked from chyroc/go-aliyundrive
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathshare_test.go
77 lines (64 loc) · 1.81 KB
/
share_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
package aliyundrive
import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)
func TestAliyunDrive_CreateShare(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)
shareFile, err := cli.CreateShare(context.TODO(), &CreateShareReq{
DriveId: self.DefaultDriveID,
FileIdList: []string{result.FileID},
})
assert.NoError(t, err)
assert.NotNil(t, shareFile)
assert.NotEmpty(t, shareFile.FileId)
shareUpdateResult, err := cli.UpdateShare(context.TODO(), &UpdateShareReq{
ShareId: shareFile.ShareId,
Expiration: "",
//expiration: "2022-04-07T03:00:59.588Z"
})
assert.NoError(t, err)
assert.NotNil(t, shareUpdateResult)
assert.NotEmpty(t, shareUpdateResult.ShareId)
err = cli.CancelShare(context.TODO(), &CancelShareReq{
ShareId: shareFile.ShareId,
})
assert.NoError(t, err)
err = cli.Trash(context.TODO(), &DeleteFileReq{
DriveID: self.DefaultDriveID,
FileID: result.FileID,
})
assert.NoError(t, err)
}
func TestAliyunDrive_ListShare(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)
sharedFiles, err := cli.ListShare(context.TODO(), &ListShareReq{
Creator: self.UserID,
IncludeCanceled: false,
Category: TypeFile,
})
assert.NoError(t, err)
assert.NotEmpty(t, sharedFiles.Items)
}
func TestAliyunDrive_UpdateShare(t *testing.T) {
}