refactor(exec_test.go): simplify tests and update plugin.yaml

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2025-05-21 07:49:45 +08:00
parent ef7c321ff4
commit be9c98b355
3 changed files with 10 additions and 15 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"github.com/tj/assert"
"go.uber.org/zap"
)
@ -503,12 +504,9 @@ func Test_DecryptSecret(t *testing.T) {
expected := fmt.Sprintf(`Preparing to decrypt secret %v/secretName
Decrypting secret %s/secretName
exec: helm --kubeconfig config --kube-context dev secrets decrypt %s/secretName
Decrypted %s/secretName into %s
Preparing to decrypt secret %s/secretName
Found secret in cache %s/secretName
Decrypted %s/secretName into %s
`, cwd, cwd, cwd, cwd, tmpFilePath, cwd, cwd, cwd, tmpFilePath)
`, cwd, cwd, cwd, cwd)
if err != nil {
if _, ok := err.(*os.PathError); ok {
} else {
@ -551,9 +549,7 @@ func Test_DecryptSecretWithGotmpl(t *testing.T) {
expected := fmt.Sprintf(`Preparing to decrypt secret %v/secretName.yaml.gotmpl
Decrypting secret %s/secretName.yaml.gotmpl
exec: helm --kubeconfig config --kube-context dev secrets decrypt %s/secretName.yaml.gotmpl
Decrypted %s/secretName.yaml.gotmpl into %s
`, cwd, cwd, cwd, cwd, tmpFilePath)
`, cwd, cwd)
if err != nil {
t.Errorf("Error: %v", err)
}
@ -996,17 +992,14 @@ func Test_GetPluginVersion(t *testing.T) {
v4PluginDirPath := "../../test/plugins/secrets/4.0.0"
v3SecretPluginVersion, err := GetPluginVersion("secrets", v3PluginDirPath)
if err != nil {
t.Error(err.Error())
}
require.NoError(t, err)
if v3SecretPluginVersion.String() != v3ExpectedVersion {
t.Errorf("secrets v3 plugin version is %v, expected %v", v3SecretPluginVersion.String(), v3ExpectedVersion)
}
v4SecretPluginVersion, err := GetPluginVersion("secrets", v4PluginDirPath)
if err != nil {
t.Error(err.Error())
}
require.NoError(t, err)
if v4SecretPluginVersion.String() != v4ExpectedVersion {
t.Errorf("secrets v4 plugin version is %v, expected %v", v4SecretPluginVersion.String(), v4ExpectedVersion)
}

View File

@ -4,8 +4,9 @@ usage: "Secrets encryption in Helm for Git storing"
description: |-
This plugin provides secrets values encryption for Helm charts secure storing
useTunnel: false
command: "$HELM_PLUGIN_DIR/scripts/run.sh"
platformCommand:
- os: linux
command: "$HELM_PLUGIN_DIR/scripts/run.sh"
- os: windows
command: "cmd /c $HELM_PLUGIN_DIR\\scripts\\wrapper\\sh.cmd $HELM_PLUGIN_DIR\\scripts\\run.sh"

View File

@ -4,8 +4,9 @@ usage: "Secrets encryption in Helm for Git storing"
description: |-
This plugin provides secrets values encryption for Helm charts secure storing
useTunnel: false
command: "$HELM_PLUGIN_DIR/scripts/run.sh"
platformCommand:
- os: linux
command: "$HELM_PLUGIN_DIR/scripts/run.sh"
- os: windows
command: "cmd /c $HELM_PLUGIN_DIR\\scripts\\wrapper\\sh.cmd $HELM_PLUGIN_DIR\\scripts\\run.sh"