diff --git a/cli/run_util.go b/cli/run_util.go index 3e54d45fc..abb8e2228 100644 --- a/cli/run_util.go +++ b/cli/run_util.go @@ -596,9 +596,8 @@ func expandStepInputs( } for index, environmentItem := range environments { - envValue := environmentItem[key] - if envValue != nil { - return os.Expand(envValue.(string), mappingFuncFactory(environments[:index])) + if envKey, envValue, err := environmentItem.GetKeyValuePair(); err == nil && envKey == key { + return os.Expand(envValue, mappingFuncFactory(environments[:index])) } } diff --git a/cli/run_util_test.go b/cli/run_util_test.go index eeb861848..eda761e11 100644 --- a/cli/run_util_test.go +++ b/cli/run_util_test.go @@ -797,6 +797,46 @@ func TestExpandStepInputsNeedExpansion(t *testing.T) { require.Equal(t, "13.3", expandedInputs["simulator_os_version"]) } +func TestExpandStepInputsNeedsFloatExpansion(t *testing.T) { + // Arrange + testInputs := []envmanModels.EnvironmentItemModel{ + envmanModels.EnvironmentItemModel{"simulator_os_version": "$SIMULATOR_OS_VERSION", "opts": map[string]interface{}{"is_sensitive": false}}, + envmanModels.EnvironmentItemModel{"simulator_device": "iPhone 8 Plus", "opts": map[string]interface{}{"is_sensitive": false}}, + } + + testEnvironment := []envmanModels.EnvironmentItemModel{ + envmanModels.EnvironmentItemModel{"SIMULATOR_OS_VERSION": 13.3, "opts": map[string]interface{}{"is_sensitive": false}}, + envmanModels.EnvironmentItemModel{"SIMULATOR_DEVICE_BOOL": true, "opts": map[string]interface{}{"is_sensitive": false}}, + } + + // Act + expandedInputs := expandStepInputs(testInputs, testEnvironment) + + // Assert + require.NotNil(t, expandedInputs) + require.Equal(t, "iPhone 8 Plus", expandedInputs["simulator_device"]) + require.Equal(t, "13.3", expandedInputs["simulator_os_version"]) +} + +func TestExpandStepInputsNeedsBoolExpansion(t *testing.T) { + // Arrange + testInputs := []envmanModels.EnvironmentItemModel{ + envmanModels.EnvironmentItemModel{"random_bool": "BOOL: $RANDOM_BOOL", "opts": map[string]interface{}{"is_sensitive": false}}, + envmanModels.EnvironmentItemModel{"simulator_device": "iPhone 8 $SIMULATOR_DEVICE_BOOL", "opts": map[string]interface{}{"is_sensitive": false}}, + } + + testEnvironment := []envmanModels.EnvironmentItemModel{ + envmanModels.EnvironmentItemModel{"RANDOM_BOOL": true, "opts": map[string]interface{}{"is_sensitive": false}}, + } + + // Act + expandedInputs := expandStepInputs(testInputs, testEnvironment) + + // Assert + require.NotNil(t, expandedInputs) + require.Equal(t, "BOOL: true", expandedInputs["random_bool"]) +} + func TestExpandStepInputsNeedExpansionWithinExpansion(t *testing.T) { // Arrange testInputs := []envmanModels.EnvironmentItemModel{