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) + }) + } +}