1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-20 16:59:17 +08:00
1Panel/backend/app/service/snapshot_test.go

54 lines
1.5 KiB
Go
Raw Normal View History

2023-01-06 18:53:25 +08:00
package service
import (
"context"
2023-01-06 18:53:25 +08:00
"fmt"
"io/ioutil"
2023-01-06 18:53:25 +08:00
"testing"
2023-01-30 21:05:20 +08:00
"time"
2023-01-06 18:53:25 +08:00
2023-01-30 21:05:20 +08:00
"github.com/1Panel-dev/1Panel/backend/init/log"
"github.com/1Panel-dev/1Panel/backend/init/viper"
"github.com/1Panel-dev/1Panel/backend/utils/files"
"github.com/google/go-github/github"
2023-01-06 18:53:25 +08:00
)
func TestDi(t *testing.T) {
2023-01-30 21:05:20 +08:00
viper.Init()
log.Init()
ti := time.Now().Format("20060102150405")
oss := "https://1panel.oss-cn-hangzhou.aliyuncs.com"
tmpPath := fmt.Sprintf("/opt/1Panel/data/tmp/%s_upgrade.tar.gz", ti)
fileOp := files.NewFileOp()
downloadPath := fmt.Sprintf("%s/releases/v1.0.1/v1.0.1.tar.gz", oss)
if err := fileOp.DownloadFile(downloadPath, tmpPath); err != nil {
fmt.Println(err)
}
}
func TestGit(t *testing.T) {
client := github.NewClient(nil)
stats, _, err := client.Repositories.GetLatestRelease(context.Background(), "KubeOperator", "KubeOperator")
fmt.Println(github.Timestamp(*stats.PublishedAt), err)
}
func TestSdasd(t *testing.T) {
u := NewISnapshotService()
var snapjson SnapshotJson
snapjson, _ = u.readFromJson("/Users/slooop/Downloads/snapshot.json")
fmt.Println(111, snapjson)
// if err := ioutil.WriteFile("/Users/slooop/Downloads/snapshot.json", []byte("111xxxxx"), 0640); err != nil {
// fmt.Println(err)
// }
}
func TestCp(t *testing.T) {
_, err := ioutil.ReadFile("/Users/slooop/Downloads/test/main")
if err != nil {
fmt.Println(err)
}
if err := ioutil.WriteFile("/Users/slooop/Downloads/test/main", []byte("sdadasd"), 0640); err != nil {
fmt.Println(err)
}
2023-01-06 18:53:25 +08:00
}