diff --git a/azurerm/internal/services/automation/automation_variable.go b/azurerm/internal/services/automation/automation_variable.go index 4c63e9d70127..e93f11470ff7 100644 --- a/azurerm/internal/services/automation/automation_variable.go +++ b/azurerm/internal/services/automation/automation_variable.go @@ -40,11 +40,11 @@ func ParseAzureAutomationVariableValue(resource string, input *string) (interfac } } else if value, err = strconv.Unquote(*input); err == nil { actualResource = "azurerm_automation_variable_string" - } else if value, err = strconv.ParseBool(*input); err == nil { - actualResource = "azurerm_automation_variable_bool" } else if value, err = strconv.ParseInt(*input, 10, 32); err == nil { value = int32(value.(int64)) actualResource = "azurerm_automation_variable_int" + } else if value, err = strconv.ParseBool(*input); err == nil { + actualResource = "azurerm_automation_variable_bool" } if actualResource != resource { diff --git a/azurerm/internal/services/automation/automation_variable_test.go b/azurerm/internal/services/automation/automation_variable_test.go index 9445011c9c3a..5a7184fe0367 100644 --- a/azurerm/internal/services/automation/automation_variable_test.go +++ b/azurerm/internal/services/automation/automation_variable_test.go @@ -33,7 +33,7 @@ func TestParseAzureRmAutomationVariableValue(t *testing.T) { Expect: func(v interface{}) bool { return v.(string) == "Test String" }, }, { - Name: "integer variable", + Name: "integer variable 135", Resource: "azurerm_automation_variable_int", Value: "135", HasError: false, @@ -41,13 +41,45 @@ func TestParseAzureRmAutomationVariableValue(t *testing.T) { Expect: func(v interface{}) bool { return v.(int32) == 135 }, }, { - Name: "boolean variable", + Name: "integer variable 0", + Resource: "azurerm_automation_variable_int", + Value: "0", + HasError: false, + ExpectValue: 0, + Expect: func(v interface{}) bool { return v.(int32) == 0 }, + }, + { + Name: "integer variable 1", + Resource: "azurerm_automation_variable_int", + Value: "1", + HasError: false, + ExpectValue: 1, + Expect: func(v interface{}) bool { return v.(int32) == 1 }, + }, + { + Name: "integer variable 2", + Resource: "azurerm_automation_variable_int", + Value: "2", + HasError: false, + ExpectValue: 2, + Expect: func(v interface{}) bool { return v.(int32) == 2 }, + }, + { + Name: "boolean variable true", Resource: "azurerm_automation_variable_bool", Value: "true", HasError: false, ExpectValue: true, Expect: func(v interface{}) bool { return v.(bool) == true }, }, + { + Name: "boolean variable false", + Resource: "azurerm_automation_variable_bool", + Value: "false", + HasError: false, + ExpectValue: false, + Expect: func(v interface{}) bool { return v.(bool) == false }, + }, { Name: "datetime variable", Resource: "azurerm_automation_variable_datetime",