update tests

Signed-off-by: yxxhero <aiopsclub@163.com>
pull/31514/head
yxxhero 3 months ago
parent 2d49f0cb4a
commit 8c87024860

@ -16,7 +16,6 @@ limitations under the License.
package plugin
import (
"os"
"reflect"
"runtime"
"testing"
@ -225,7 +224,6 @@ func TestPrepareCommandsNoCommands(t *testing.T) {
}
func TestPrepareCommandsExpand(t *testing.T) {
t.Setenv("TESTX", "testx")
cmdMain := "sh"
cmdArgs := []string{"-c", "echo \"${TESTX}${TESTY}\""}
cmds := []PlatformCommand{
@ -234,8 +232,10 @@ func TestPrepareCommandsExpand(t *testing.T) {
expectedArgs := []string{"-c", "echo \"testxtesty\""}
env := parseEnv(os.Environ())
env["TESTY"] = "testy"
env := map[string]string{
"TESTX": "testx",
"TESTY": "testy",
}
cmd, args, err := PrepareCommands(cmds, true, []string{}, env)
if err != nil {
@ -250,13 +250,15 @@ func TestPrepareCommandsExpand(t *testing.T) {
}
func TestPrepareCommandsNoExpand(t *testing.T) {
t.Setenv("TEST", "test")
cmdMain := "sh"
cmdArgs := []string{"-c", "echo \"${TEST}\""}
cmds := []PlatformCommand{
{OperatingSystem: "", Architecture: "", Command: cmdMain, Args: cmdArgs},
}
env := parseEnv(os.Environ())
env := map[string]string{
"TEST": "test",
}
cmd, args, err := PrepareCommands(cmds, false, []string{}, env)
if err != nil {

Loading…
Cancel
Save