|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package cdsapi
-
- import (
- "testing"
-
- . "github.com/smartystreets/goconvey/convey"
- "gitlink.org.cn/cloudream/common/pkgs/types"
- )
-
- func Test_Presigned(t *testing.T) {
- cli := NewClient(&Config{
- URL: "http://localhost:7890",
- })
-
- Convey("下载文件", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectDownload(PresignedObjectDownloadByPath{
- UserID: 1,
- PackageID: 3,
- Path: "example.java",
- Offset: 1,
- Length: types.Ref(int64(100)),
- }, 100)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
-
- Convey("上传文件", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectUpload(PresignedObjectUpload{
- UserID: 1,
- PackageID: 3,
- Path: "example.java",
- }, 100)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
- }
-
- func Test_PresignedObjectDownload(t *testing.T) {
- cli := NewClient(&Config{
- URL: "http://localhost:7890",
- })
-
- Convey("下载文件", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectDownload(PresignedObjectDownloadByPath{
- UserID: 1,
- PackageID: 3,
- Path: "example.java",
- // Offset: 1,
- // Length: types.Ref(int64(100)),
- }, 100)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
- }
-
- func Test_PresignedObjectUpload(t *testing.T) {
- cli := NewClient(&Config{
- URL: "http://localhost:7890",
- })
-
- Convey("上传文件", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectUpload(PresignedObjectUpload{
- UserID: 1,
- PackageID: 3,
- Path: "example.java",
- }, 100)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
- }
-
- func Test_PresignedNewMultipartUpload(t *testing.T) {
- cli := NewClient(&Config{
- URL: "http://localhost:7890",
- })
-
- Convey("启动分片上传", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectNewMultipartUpload(PresignedObjectNewMultipartUpload{
- UserID: 1,
- PackageID: 3,
- Path: "example.java",
- }, 600)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
- }
-
- func Test_PresignedObjectUploadPart(t *testing.T) {
- cli := NewClient(&Config{
- URL: "http://localhost:7890",
- })
-
- Convey("上传分片", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectUploadPart(PresignedObjectUploadPart{
- UserID: 1,
- ObjectID: 7,
- Index: 3,
- }, 600)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
- }
-
- func Test_PresignedCompleteMultipartUpload(t *testing.T) {
- cli := NewClient(&Config{
- URL: "http://localhost:7890",
- })
-
- Convey("合并分片", t, func() {
- pre := cli.Presigned("123456", "123456")
- url, err := pre.ObjectCompleteMultipartUpload(PresignedObjectCompleteMultipartUpload{
- UserID: 1,
- ObjectID: 7,
- Indexes: []int{1, 2, 3},
- }, 600)
- So(err, ShouldEqual, nil)
- t.Logf("url: %s", url)
- })
- }
|