This commit is contained in:
admju
2024-09-04 07:11:13 +00:00
parent d12d3e31bf
commit 48301bf82e
17 changed files with 210 additions and 25 deletions

View File

@@ -7,14 +7,14 @@ import (
func Version(path string) (string, error) {
cmd := exec.Command(path, "version", "--short")
stdout, err := cmd.CombinedOutput()
cmd := exec.Command(path, "version", "--short")
stdout, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
res := string(stdout)
res = strings.TrimSuffix(res, "\n")
res := string(stdout)
res = strings.TrimSuffix(res, "\n")
return res, nil
}

View File

@@ -1,22 +1,22 @@
package helm
import (
"os"
"path/filepath"
"os"
"path/filepath"
"testing"
"testing"
"github.com/stretchr/testify/assert"
)
func TestHelmVersion(t *testing.T){
bin := filepath.Join(TEST_BIN_DIR, "helm")
os.Chmod(bin, 0700)
bin := filepath.Join(TEST_BIN_DIR, "helm")
os.Chmod(bin, 0700)
assert.FileExists(t, bin, "TestHelmVersion error")
version, err := Version(bin)
version, err := Version(bin)
assert.Nilf(t, err, "error message %s", bin)
assert.Equal(t, version, "v3.15.4+gfa9efb0", "TestHelmVersion error")
assert.Nilf(t, err, "error message %s", bin)
assert.Equal(t, "v3.15.4+gfa9efb0", version, "TestHelmVersion error")
}