Skip to content

Commit

Permalink
encode test ids as constants for easy replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
mtbrandy authored and hkantare committed Jan 30, 2024
1 parent 35e4ed8 commit c116881
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (
acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest"
)

const (
testAccountID = "12ab34cd56ef78ab90cd12ef34ab56cd"
testZoneID = "559052eb8f43302824e7ae490c0281eb"
)

func TestAccIBMCbrRuleDataSourceBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Expand Down Expand Up @@ -77,13 +82,13 @@ func testAccCheckIBMCbrRuleDataSourceConfigBasic() string {
contexts {
attributes {
name = "networkZoneId"
value = "559052eb8f43302824e7ae490c0281eb"
value = "%s"
}
}
resources {
attributes {
name = "accountId"
value = "12ab34cd56ef78ab90cd12ef34ab56cd"
value = "%s"
}
attributes {
name = "serviceName"
Expand All @@ -94,7 +99,7 @@ func testAccCheckIBMCbrRuleDataSourceConfigBasic() string {
data "ibm_cbr_rule" "cbr_rule" {
rule_id = ibm_cbr_rule.cbr_rule.id
}
`)
`, testZoneID, testAccountID)
}

func testAccCheckIBMCbrRuleDataSourceConfig(ruleDescription string, ruleEnforcementMode string) string {
Expand All @@ -104,13 +109,13 @@ func testAccCheckIBMCbrRuleDataSourceConfig(ruleDescription string, ruleEnforcem
contexts {
attributes {
name = "networkZoneId"
value = "559052eb8f43302824e7ae490c0281eb"
value = "%s"
}
}
resources {
attributes {
name = "accountId"
value = "12ab34cd56ef78ab90cd12ef34ab56cd"
value = "%s"
}
attributes {
name = "serviceName"
Expand All @@ -133,5 +138,5 @@ func testAccCheckIBMCbrRuleDataSourceConfig(ruleDescription string, ruleEnforcem
data "ibm_cbr_rule" "cbr_rule" {
rule_id = ibm_cbr_rule.cbr_rule.id
}
`, ruleDescription, ruleEnforcementMode)
`, ruleDescription, testZoneID, testAccountID, ruleEnforcementMode)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAccIBMCbrZoneDataSourceBasic(t *testing.T) {

func TestAccIBMCbrZoneDataSourceAllArgs(t *testing.T) {
zoneName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100))
zoneAccountID := "12ab34cd56ef78ab90cd12ef34ab56cd"
zoneAccountID := testAccountID
zoneDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -86,7 +86,7 @@ func testAccCheckIBMCbrZoneDataSourceConfigBasic() string {
resource "ibm_cbr_zone" "cbr_zone" {
name = "Test Zone Data Source Config Basic"
description = "Test Zone Data Source Config Basic"
account_id = "12ab34cd56ef78ab90cd12ef34ab56cd"
account_id = "%s"
addresses {
type = "ipRange"
value = "169.23.22.0-169.23.22.255"
Expand All @@ -96,7 +96,7 @@ func testAccCheckIBMCbrZoneDataSourceConfigBasic() string {
data "ibm_cbr_zone" "cbr_zone" {
zone_id = ibm_cbr_zone.cbr_zone.id
}
`)
`, testAccountID)
}

func testAccCheckIBMCbrZoneDataSourceConfig(zoneName string, zoneAccountID string, zoneDescription string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func testAccCheckIBMCbrRuleConfigBasic() string {
contexts {
attributes {
name = "networkZoneId"
value = "559052eb8f43302824e7ae490c0281eb"
value = "%s"
}
}
resources {
attributes {
name = "accountId"
value = "12ab34cd56ef78ab90cd12ef34ab56cd"
value = "%s"
}
attributes {
name = "serviceName"
Expand All @@ -97,7 +97,7 @@ func testAccCheckIBMCbrRuleConfigBasic() string {
}
enforcement_mode = "disabled"
}
`)
`, testZoneID, testAccountID)
}

func testAccCheckIBMCbrRuleConfig(description string, enforcementMode string) string {
Expand All @@ -108,13 +108,13 @@ func testAccCheckIBMCbrRuleConfig(description string, enforcementMode string) st
contexts {
attributes {
name = "networkZoneId"
value = "559052eb8f43302824e7ae490c0281eb"
value = "%s"
}
}
resources {
attributes {
name = "accountId"
value = "12ab34cd56ef78ab90cd12ef34ab56cd"
value = "%s"
}
attributes {
name = "serviceName"
Expand All @@ -133,7 +133,7 @@ func testAccCheckIBMCbrRuleConfig(description string, enforcementMode string) st
}
enforcement_mode = "%s"
}
`, description, enforcementMode)
`, description, testZoneID, testAccountID, enforcementMode)
}

func testAccCheckIBMCbrRuleExists(n string, obj contextbasedrestrictionsv1.Rule) resource.TestCheckFunc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func TestAccIBMCbrZoneBasic(t *testing.T) {
func TestAccIBMCbrZoneAllArgs(t *testing.T) {
var conf contextbasedrestrictionsv1.Zone
name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100))
accountID := fmt.Sprintf("12ab34cd56ef78ab90cd12ef34ab56cd")
accountID := testAccountID
description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100))
nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100))
accountIDUpdate := fmt.Sprintf("12ab34cd56ef78ab90cd12ef34ab56cd")
accountIDUpdate := testAccountID
descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -79,13 +79,13 @@ func testAccCheckIBMCbrZoneConfigBasic() string {
resource "ibm_cbr_zone" "cbr_zone" {
name = "Test Zone Resource Config Basic"
description = "Test Zone Resource Config Basic"
account_id = "12ab34cd56ef78ab90cd12ef34ab56cd"
account_id = "%s"
addresses {
type = "ipRange"
value = "169.23.22.0-169.23.22.255"
}
}
`)
`, testAccountID)
}

func testAccCheckIBMCbrZoneConfig(name string, accountID string, description string) string {
Expand Down

0 comments on commit c116881

Please sign in to comment.