From b3b3be448fe6dd81c319e433086b974e0608d4c9 Mon Sep 17 00:00:00 2001 From: razeen Date: Wed, 11 Aug 2021 08:31:04 -0700 Subject: [PATCH] chore(qiniu): qiniu upload remove zone, support all zone upload --- pkg/internal/qiniu.go | 1 - pkg/internal/qiniu_test.go | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 pkg/internal/qiniu_test.go diff --git a/pkg/internal/qiniu.go b/pkg/internal/qiniu.go index c31e94a..dd8c0b0 100644 --- a/pkg/internal/qiniu.go +++ b/pkg/internal/qiniu.go @@ -42,7 +42,6 @@ func QiniuUpload(params UploadParams) (string, error) { uploadToken := putPolicy.UploadToken(mac) // 上传配置 cfg := &storage.Config{ - Zone: &storage.ZoneHuadong, UseHTTPS: true, } // uploader diff --git a/pkg/internal/qiniu_test.go b/pkg/internal/qiniu_test.go new file mode 100644 index 0000000..7695acb --- /dev/null +++ b/pkg/internal/qiniu_test.go @@ -0,0 +1,47 @@ +// Package internal provides ... +package internal + +import ( + "os" + "testing" + "time" + + "github.com/eiblog/eiblog/pkg/config" +) + +func TestQiniuUpload(t *testing.T) { + + f, _ := os.Open("qiniu_test.go") + fi, _ := f.Stat() + + type args struct { + params UploadParams + } + tests := []struct { + name string + args args + wantErr bool + }{ + // TODO: Add test cases. + {"1", args{params: UploadParams{ + Name: "test-" + time.Now().Format("200601021504059999") + ".go", + Size: fi.Size(), + Data: f, + Conf: config.Qiniu{ + AccessKey: os.Getenv("QINIU_ACCESSKEY"), + SecretKey: os.Getenv("QINIU_SECRETKEY"), + Bucket: os.Getenv("QINIU_BUCKET"), + }, + }}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := QiniuUpload(tt.args.params) + if (err != nil) != tt.wantErr { + t.Errorf("QiniuUpload() error = %v, wantErr %v", err, tt.wantErr) + return + } + t.Logf("QiniuUpload() = %v", got) + }) + } +}