update tests

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

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

Loading…
Cancel
Save