test
This commit is contained in:
28
src/tool/conf_test.go
Normal file
28
src/tool/conf_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
// "os"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"testing"
|
||||
|
||||
// "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestToolConf(t *testing.T) {
|
||||
|
||||
src := filepath.Join(TEST_SRC_DIR, "oc.yml")
|
||||
|
||||
data, err := FromConfigFile(src)
|
||||
fmt.Println("data", src, data, err)
|
||||
|
||||
// bin := filepath.Join(TEST_BIN_DIR, "kubectl")
|
||||
// os.Chmod(bin, 0700)
|
||||
// assert.FileExists(t, bin, "TestKubectlVersion error")
|
||||
|
||||
// version, err := Version(bin)
|
||||
|
||||
// assert.Nilf(t, err, "error message %s", bin)
|
||||
// assert.Equal(t, "v1.30.3", version, "TestKubectlVersion error")
|
||||
}
|
||||
@@ -22,7 +22,6 @@ func (this HelmInstallData) Download() (error) {
|
||||
bin_dir := this.obj.Bin
|
||||
err2 := os.MkdirAll(bin_dir, os.ModePerm)
|
||||
if err2 != nil {
|
||||
fmt.Println(err2)
|
||||
return err2
|
||||
}
|
||||
|
||||
|
||||
24
src/tool/main_test.go
Normal file
24
src/tool/main_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var TEST_DEST_DIR = "../wrk_tool"
|
||||
var TEST_SRC_DIR = filepath.Join("../../test", "tool")
|
||||
var TEST_BIN_DIR = filepath.Join("../../test", "bin")
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
folderPath := TEST_DEST_DIR
|
||||
|
||||
os.RemoveAll(folderPath)
|
||||
os.MkdirAll(folderPath, os.ModePerm)
|
||||
|
||||
// call flag.Parse() here if TestMain uses flags
|
||||
exitCode := m.Run()
|
||||
|
||||
os.RemoveAll(folderPath)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
Reference in New Issue
Block a user