Rainbond/builder/exector/groupapp_backup_test.go

62 lines
1.9 KiB
Go
Raw Normal View History

2019-11-05 11:30:11 +08:00
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package exector
import (
2019-11-05 11:32:55 +08:00
"fmt"
"github.com/goodrain/rainbond/util"
2019-11-05 11:30:11 +08:00
"testing"
)
func TestUploadPkg(t *testing.T) {
b := &BackupAPPNew{
SourceDir: "/tmp/groupbackup/0d65c6608729438aad0a94f6317c80d0_20191024180024.zip",
Mode: "full-online",
}
b.S3Config.Provider = "AliyunOSS"
b.S3Config.Endpoint = "dummy"
b.S3Config.AccessKey = "dummy"
b.S3Config.SecretKey = "dummy"
b.S3Config.BucketName = "dummy"
if err := b.uploadPkg(); err != nil {
t.Errorf("unexpected error: %v", err)
}
}
2019-11-05 11:32:55 +08:00
func TestUploadPkg2(t *testing.T) {
b := &BackupAPPRestore{}
b.S3Config.Provider = "alioss"
b.S3Config.Endpoint = "dummy"
b.S3Config.AccessKey = "dummy"
b.S3Config.SecretKey = "dummy"
b.S3Config.BucketName = "hrhtest"
cacheDir := fmt.Sprintf("/tmp/cache/tmp/%s/%s", "c6b05a2a6d664fda83dab8d3bcf1a941", util.NewUUID())
if err := util.CheckAndCreateDir(cacheDir); err != nil {
t.Errorf("create cache dir error %s", err.Error())
}
b.cacheDir = cacheDir
sourceDir := "/tmp/groupbackup/c6b05a2a6d664fda83dab8d3bcf1a941_20191024185643.zip"
if err := b.downloadFromS3(sourceDir); err != nil {
t.Error(err)
}
}