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

31 lines
569 B
Go
Raw Normal View History

2022-10-21 18:50:38 +08:00
package service
import (
"compress/gzip"
2022-10-21 18:50:38 +08:00
"fmt"
"os"
2022-10-25 18:34:33 +08:00
"os/exec"
2022-10-21 18:50:38 +08:00
"testing"
_ "github.com/go-sql-driver/mysql"
)
func TestMysql(t *testing.T) {
gzipFile, err := os.Open("/tmp/ko.sql.gz")
2022-10-21 18:50:38 +08:00
if err != nil {
fmt.Println(err)
}
defer gzipFile.Close()
gzipReader, err := gzip.NewReader(gzipFile)
if err != nil {
fmt.Println(err)
}
defer gzipReader.Close()
cmd := exec.Command("docker", "exec", "-i", "365", "mysql", "-uroot", "-pCalong@2012", "kubeoperator")
cmd.Stdin = gzipReader
stdout, err := cmd.CombinedOutput()
fmt.Println(string(stdout), err)
}