This commit is contained in:
admju
2024-09-09 14:17:02 +00:00
parent 550675a4aa
commit 13025746e6
32 changed files with 1597 additions and 664 deletions

View File

@@ -1,22 +1,33 @@
package kubectl
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestKubectlVersion(t *testing.T){
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")
}
package kubectl
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestKubectlVersion(t *testing.T) {
cmd_json := `
{
"clientVersion": {
"major": "1",
"minor": "30",
"gitVersion": "v1.30.3",
"gitCommit": "6fc0a69044f1ac4c13841ec4391224a2df241460",
"gitTreeState": "clean",
"buildDate": "2024-07-16T23:54:40Z",
"goVersion": "go1.22.5",
"compiler": "gc",
"platform": "linux/amd64"
},
"kustomizeVersion": "v5.0.4-0.20230601165947-6ce0bf390ce3"
}`
cmd := getCmdKubectl(true, cmd_json)
version, err := cmd.GetVersion()
assert.Nilf(t, err, "error message %s", err)
assert.Equal(t, "v1.30.3", version, "TestkubectlVersion error")
}