1 Star 0 Fork 12

名字长点才好记 / CloudStore

forked from 进击的皇虫 / CloudStore 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
qiniu_test.go 1.90 KB
一键复制 编辑 原始数据 按行查看 历史
TruthHun 提交于 2019-03-18 23:16 . 云存储测试用例
package CloudStore
import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"github.com/astaxie/beego"
)
var (
objectQiniu = "qiniu.go"
Qiniu *QINIU
)
func init() {
key := beego.AppConfig.String("qiniu::accessKey")
secret := beego.AppConfig.String("qiniu::secretKey")
bucket := beego.AppConfig.String("qiniu::bucket")
domain := strings.ToLower(beego.AppConfig.String("qiniu::domain"))
Qiniu, err = NewQINIU(key, secret, bucket, domain)
if err != nil {
panic(err)
}
}
func TestQINIU(t *testing.T) {
// upload
t.Log("=====Upload=====", objectSVG, objectSVGGzip)
err = Qiniu.Upload(objectSVG, objectSVG,headerSVG)
if err != nil {
t.Error(err)
}
err = Qiniu.Upload(objectSVGGzip, objectSVGGzip, headerGzip, headerSVG)
if err != nil {
t.Error(err)
}
t.Log("=====IsExist=====")
t.Log(objectSVG, "is exist?(Y):", Qiniu.IsExist(objectSVG) == nil)
t.Log(objectNotExist, "is exist?(N):", Qiniu.IsExist(objectNotExist) == nil)
t.Log("=====Lists=====")
if files, err := Qiniu.Lists(objectPrefix); err != nil {
t.Error(err)
} else {
t.Log(fmt.Sprintf("%+v", files))
}
t.Log("=====GetInfo=====")
if info, err := Qiniu.GetInfo(objectSVG); err != nil {
t.Error(err.Error())
} else {
t.Log(fmt.Sprintf("%+v", info))
}
t.Log("=====Download=====")
if err := Qiniu.Download(objectSVG, objectDownload); err != nil {
t.Error(err)
} else {
t.Log("download success")
b, _ := ioutil.ReadFile(objectDownload)
t.Log("Content:", string(b))
os.Remove(objectDownload)
}
t.Log("====GetSignURL====")
t.Log(Qiniu.GetSignURL(objectSVG, 1200))
t.Log(Qiniu.GetSignURL(objectSVGGzip, 1200))
t.Log("========Finished========")
}
func TestQINIU_Delete(t *testing.T) {
if err := Qiniu.Delete(objectSVG, objectSVGGzip); err != nil {
t.Error(err)
} else {
t.Log("delete success")
}
if files, err := Qiniu.Lists(objectPrefix); err != nil {
t.Error(err)
} else {
t.Log(fmt.Sprintf("%+v", files))
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kaopuke/CloudStore.git
git@gitee.com:kaopuke/CloudStore.git
kaopuke
CloudStore
CloudStore
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891