update tests

Signed-off-by: yxxhero <aiopsclub@163.com>
(cherry picked from commit 8c87024860)
pull/31646/head
yxxhero 1 month ago committed by Matt Farina
parent 77f97a169e
commit b2f7872695
No known key found for this signature in database
GPG Key ID: 92C44A3D421FF7F9

@ -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