From 4bf4073e33405a91517c52d84d48193170c23dab Mon Sep 17 00:00:00 2001 From: Matthew Cummings Date: Sun, 10 Dec 2023 20:17:37 -0500 Subject: [PATCH] unindent a test file --- cloudtruth/resource_parameter_test.go | 307 +++++++++++++------------- 1 file changed, 153 insertions(+), 154 deletions(-) diff --git a/cloudtruth/resource_parameter_test.go b/cloudtruth/resource_parameter_test.go index 818f1fb..63b75c9 100644 --- a/cloudtruth/resource_parameter_test.go +++ b/cloudtruth/resource_parameter_test.go @@ -4,149 +4,149 @@ import ( "fmt" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "regexp" "strconv" "testing" ) -/* - func TestAccResourceParameterWithRules(t *testing.T) { - createStringParamName := fmt.Sprintf("Test-Str-%s", uuid.New().String()) - createIntegerParamName := fmt.Sprintf("Test-Int-%s", uuid.New().String()) - stringResourceName, intResourceName := "string_with_rules", "int_with_rules" - minVal, maxVal := 1, 10 - createRegEx := ".*" - updateMin, updateMax := 0, 11 - updateRegEx := `123.*` - resource.Test(t, resource.TestCase{ - ProviderFactories: testProviderFactories, - PreCheck: func() { testAccPreCheck(t) }, - Steps: []resource.TestStep{ - { - Config: testAccResourceParameterCreateStringWithRules(accTestProject, stringResourceName, createStringParamName, paramDesc, - false, minVal, maxVal, createRegEx), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "min", fmt.Sprint(minVal)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "max", fmt.Sprint(maxVal)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", createRegEx), - ), - }, - { - Config: testAccResourceParameterCreateStringWithRules(accTestProject, stringResourceName, createStringParamName, updateParamDesc, - false, updateMin, updateMax, updateRegEx), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", updateParamDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", fmt.Sprint(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "min", fmt.Sprint(updateMin)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "max", fmt.Sprint(updateMax)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", updateRegEx), - ), - }, - { - Config: testAccResourceParameterCreateIntegerWithRules(accTestProject, intResourceName, createIntegerParamName, paramDesc, - false, minVal, maxVal), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntegerParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", fmt.Sprint(minVal)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", fmt.Sprint(maxVal)), - ), - }, - { - Config: testAccResourceParameterCreateIntegerWithRules(accTestProject, intResourceName, createIntegerParamName, paramDesc, - false, updateMin, updateMax), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntegerParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", fmt.Sprint(updateMin)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", fmt.Sprint(updateMax)), - ), - }, +func TestAccResourceParameterWithRules(t *testing.T) { + createStringParamName := fmt.Sprintf("Test-Str-%s", uuid.New().String()) + createIntegerParamName := fmt.Sprintf("Test-Int-%s", uuid.New().String()) + stringResourceName, intResourceName := "string_with_rules", "int_with_rules" + minVal, maxVal := 1, 10 + createRegEx := ".*" + updateMin, updateMax := 0, 11 + updateRegEx := `123.*` + resource.Test(t, resource.TestCase{ + ProviderFactories: testProviderFactories, + PreCheck: func() { testAccPreCheck(t) }, + Steps: []resource.TestStep{ + { + Config: testAccResourceParameterCreateStringWithRules(accTestProject, stringResourceName, createStringParamName, paramDesc, + false, minVal, maxVal, createRegEx), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "min", fmt.Sprint(minVal)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "max", fmt.Sprint(maxVal)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", createRegEx), + ), }, - }) - } + { + Config: testAccResourceParameterCreateStringWithRules(accTestProject, stringResourceName, createStringParamName, updateParamDesc, + false, updateMin, updateMax, updateRegEx), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", updateParamDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", fmt.Sprint(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "min", fmt.Sprint(updateMin)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "max", fmt.Sprint(updateMax)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", updateRegEx), + ), + }, + { + Config: testAccResourceParameterCreateIntegerWithRules(accTestProject, intResourceName, createIntegerParamName, paramDesc, + false, minVal, maxVal), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntegerParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", fmt.Sprint(minVal)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", fmt.Sprint(maxVal)), + ), + }, + { + Config: testAccResourceParameterCreateIntegerWithRules(accTestProject, intResourceName, createIntegerParamName, paramDesc, + false, updateMin, updateMax), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntegerParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", fmt.Sprint(updateMin)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", fmt.Sprint(updateMax)), + ), + }, + }, + }) +} - func TestAccResourceStringParameterAddRemoveRule(t *testing.T) { - createStringParamName := fmt.Sprintf("Test-Str-%s", uuid.New().String()) - stringResourceName := "string_with_rule" - createRegEx := ".*" - resource.Test(t, resource.TestCase{ - ProviderFactories: testProviderFactories, - PreCheck: func() { testAccPreCheck(t) }, - Steps: []resource.TestStep{ - { - Config: testAccResourceParameterCreateStringWithOneRule(accTestProject, stringResourceName, createStringParamName, paramDesc, - false, createRegEx), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", createRegEx), - ), - }, - { - Config: testAccResourceParameterCreateStringWithNoRules(accTestProject, stringResourceName, createStringParamName, paramDesc, - false), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", ""), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex_id", ""), - ), - }, +func TestAccResourceStringParameterAddRemoveRule(t *testing.T) { + createStringParamName := fmt.Sprintf("Test-Str-%s", uuid.New().String()) + stringResourceName := "string_with_rule" + createRegEx := ".*" + resource.Test(t, resource.TestCase{ + ProviderFactories: testProviderFactories, + PreCheck: func() { testAccPreCheck(t) }, + Steps: []resource.TestStep{ + { + Config: testAccResourceParameterCreateStringWithOneRule(accTestProject, stringResourceName, createStringParamName, paramDesc, + false, createRegEx), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", createRegEx), + ), }, - }) - } + { + Config: testAccResourceParameterCreateStringWithNoRules(accTestProject, stringResourceName, createStringParamName, paramDesc, + false), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "name", createStringParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex", ""), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", stringResourceName), "regex_id", ""), + ), + }, + }, + }) +} - func TestAccResourceIntParameterAddRemoveRule(t *testing.T) { - createIntParamName := fmt.Sprintf("Test-Int-%s", uuid.New().String()) - intResourceName := "int_with_rule" - minVal, maxVal := 0, 1000 - resource.Test(t, resource.TestCase{ - ProviderFactories: testProviderFactories, - PreCheck: func() { testAccPreCheck(t) }, - Steps: []resource.TestStep{ - { - Config: testAccResourceParameterCreateIntWithRules(accTestProject, intResourceName, createIntParamName, paramDesc, - false, minVal, maxVal), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", fmt.Sprint(minVal)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", fmt.Sprint(maxVal)), - ), - }, - { // Remove the max and min rules, their corresponding properties should be set to "" - Config: testAccResourceParameterCreateIntWithNoRules(accTestProject, intResourceName, createIntParamName, paramDesc, - false), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntParamName), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", - strconv.FormatBool(false)), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", ""), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", ""), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min_id", ""), - resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max_id", ""), - ), - }, +func TestAccResourceIntParameterAddRemoveRule(t *testing.T) { + createIntParamName := fmt.Sprintf("Test-Int-%s", uuid.New().String()) + intResourceName := "int_with_rule" + minVal, maxVal := 0, 1000 + resource.Test(t, resource.TestCase{ + ProviderFactories: testProviderFactories, + PreCheck: func() { testAccPreCheck(t) }, + Steps: []resource.TestStep{ + { + Config: testAccResourceParameterCreateIntWithRules(accTestProject, intResourceName, createIntParamName, paramDesc, + false, minVal, maxVal), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", fmt.Sprint(minVal)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", fmt.Sprint(maxVal)), + ), }, - }) - } -*/ + { // Remove the max and min rules, their corresponding properties should be set to "" + Config: testAccResourceParameterCreateIntWithNoRules(accTestProject, intResourceName, createIntParamName, paramDesc, + false), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "name", createIntParamName), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "description", paramDesc), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "secret", + strconv.FormatBool(false)), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min", ""), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max", ""), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "min_id", ""), + resource.TestCheckResourceAttr(fmt.Sprintf("cloudtruth_parameter.%s", intResourceName), "max_id", ""), + ), + }, + }, + }) +} + func TestAccResourceParameterBasic(t *testing.T) { createParamName := fmt.Sprintf("Test-%s", uuid.New().String()) resourceName := "basic" @@ -183,27 +183,26 @@ func TestAccResourceParameterBasic(t *testing.T) { }) } -/* - func TestAccResourceParameterWithBadRules(t *testing.T) { - resourceName := "bad_rules" - resource.Test(t, resource.TestCase{ - ProviderFactories: testProviderFactories, - PreCheck: func() { testAccPreCheck(t) }, - Steps: []resource.TestStep{ - { - Config: testAccResourceParameterDisallowedBooleanRules(accTestProject, resourceName, - fmt.Sprintf("Test-%s", uuid.New().String())), - ExpectError: regexp.MustCompile("the base type 'boolean' does not support rules"), - }, - { - Config: testAccResourceParameterInvalidIntegerRules(accTestProject, resourceName, - fmt.Sprintf("Test-%s", uuid.New().String())), - ExpectError: regexp.MustCompile("the base type 'integer' does not support the regex rule type"), - }, +func TestAccResourceParameterWithBadRules(t *testing.T) { + resourceName := "bad_rules" + resource.Test(t, resource.TestCase{ + ProviderFactories: testProviderFactories, + PreCheck: func() { testAccPreCheck(t) }, + Steps: []resource.TestStep{ + { + Config: testAccResourceParameterDisallowedBooleanRules(accTestProject, resourceName, + fmt.Sprintf("Test-%s", uuid.New().String())), + ExpectError: regexp.MustCompile("the base type 'boolean' does not support rules"), }, - }) - } -*/ + { + Config: testAccResourceParameterInvalidIntegerRules(accTestProject, resourceName, + fmt.Sprintf("Test-%s", uuid.New().String())), + ExpectError: regexp.MustCompile("the base type 'integer' does not support the regex rule type"), + }, + }, + }) +} + func testAccResourceParameterCreateBasic(projName, resourceName, paramName, desc string, isSecret bool) string { return fmt.Sprintf(` resource "cloudtruth_parameter" "%s" {