Skip to content

Commit

Permalink
add conflicting validation check
Browse files Browse the repository at this point in the history
  • Loading branch information
disperate committed Mar 7, 2024
1 parent 2d7a342 commit 3601403
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cloudscale/resource_cloudscale_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ func getSubnetSchema(t SchemaType) map[string]*schema.Schema {
Computed: true,
},
"disable_dns_servers": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
ConflictsWith: []string{"dns_servers"},
},
"tags": &TagsSchema,
}
Expand Down
29 changes: 29 additions & 0 deletions cloudscale/resource_cloudscale_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,23 @@ func TestAccCloudscaleSubnet_ServerWithPublicAndPrivate(t *testing.T) {
})
}

func TestAccCloudscaleSubnet_ValidationError(t *testing.T) {
rInt := acctest.RandInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudscaleSubnetDestroy,
Steps: []resource.TestStep{
{
Config: subnetconfigInvalidDnsCombination(rInt),
ExpectError: regexp.MustCompile(`Error: Conflicting configuration arguments.*`),
Check: resource.ComposeTestCheckFunc(),
},
},
})
}

func TestAccCloudscaleSubnet_ServerAndMultipleSubnets(t *testing.T) {
count := 2
networks := make([]cloudscale.Network, count, count)
Expand Down Expand Up @@ -543,6 +560,18 @@ resource "cloudscale_subnet" "basic" {
`)
}

func subnetconfigInvalidDnsCombination(rInt int) string {
return networkconfigMinimal(rInt, false) + "\n" + fmt.Sprintf(`
resource "cloudscale_subnet" "basic" {
cidr = "10.11.12.0/24"
network_uuid = cloudscale_network.basic.id
gateway_address = "10.11.12.10"
dns_servers = ["1.2.3.4", "5.6.7.8", "9.10.11.12"]
disable_dns_servers = true
}
`)
}

func serverConfigWithPublicAndLayerThree(rInt int, fixedAddress string) string {
template := `
resource "cloudscale_server" "basic" {
Expand Down

0 comments on commit 3601403

Please sign in to comment.