Skip to content

Commit

Permalink
Provide example of first_n filter usage in the create resource record…
Browse files Browse the repository at this point in the history
… test
  • Loading branch information
yshnitsar authored and alexk53 committed Apr 12, 2023
1 parent 5164bab commit bc73b5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
32 changes: 21 additions & 11 deletions gcore/resource_gcore_dns_zone_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
)

func TestAccDnsZoneRecord(t *testing.T) {

random := time.Now().Nanosecond()
domain := "terraformtest"
subDomain := fmt.Sprintf("key%d", random)
Expand All @@ -32,9 +31,14 @@ resource "%s" "%s" {
filter {
type = "geodistance"
limit = 1
strict = true
}
filter {
type = "first_n"
limit = 1
strict = false
}
resource_record {
content = "1234"
Expand All @@ -45,8 +49,8 @@ resource "%s" "%s" {
asn = [12345]
ip = ["1.1.1.1"]
notes = ["notes"]
continents = ["asia"]
countries = ["russia"]
continents = ["europe"]
countries = ["pl"]
default = true
}
}
Expand All @@ -68,8 +72,8 @@ resource "%s" "%s" {
latlong = [52.367,4.9041]
ip = ["1.1.2.2"]
notes = ["notes"]
continents = ["america"]
countries = ["usa"]
continents = ["na"]
countries = ["us"]
default = false
}
}
Expand All @@ -92,12 +96,18 @@ resource "%s" "%s" {
resource.TestCheckResourceAttr(resourceName, DNSZoneRecordSchemaTTL, "10"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s", DNSZoneRecordSchemaFilter, DNSZoneRecordSchemaFilterType),
"geodistance"),
"first_n"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s", DNSZoneRecordSchemaFilter, DNSZoneRecordSchemaFilterLimit),
"1"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s", DNSZoneRecordSchemaFilter, DNSZoneRecordSchemaFilterStrict),
"false"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.1.%s", DNSZoneRecordSchemaFilter, DNSZoneRecordSchemaFilterType),
"geodistance"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.1.%s", DNSZoneRecordSchemaFilter, DNSZoneRecordSchemaFilterStrict),
"true"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s", DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaContent),
Expand Down Expand Up @@ -128,11 +138,11 @@ resource "%s" "%s" {
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s.0.%s.0",
DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaMeta, DNSZoneRecordSchemaMetaContinents),
"asia"),
"europe"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s.0.%s.0",
DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaMeta, DNSZoneRecordSchemaMetaCountries),
"russia"),
"pl"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s.0.%s",
DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaMeta, DNSZoneRecordSchemaMetaDefault),
Expand Down Expand Up @@ -170,11 +180,11 @@ resource "%s" "%s" {
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s.0.%s.0",
DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaMeta, DNSZoneRecordSchemaMetaContinents),
"america"),
"na"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s.0.%s.0",
DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaMeta, DNSZoneRecordSchemaMetaCountries),
"usa"),
"us"),
resource.TestCheckResourceAttr(resourceName,
fmt.Sprintf("%s.0.%s.0.%s",
DNSZoneRecordSchemaResourceRecord, DNSZoneRecordSchemaMeta, DNSZoneRecordSchemaMetaDefault),
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ github.com/G-Core/gcore-dns-sdk-go v0.2.3 h1:WODi+qWlZyF7E7SH8rq/DCACa/Zhsuhu1h0
github.com/G-Core/gcore-dns-sdk-go v0.2.3/go.mod h1:TM+VaDvBPObF+x085lS3i0kc2OPAkuW2c4Leg7Pe6jI=
github.com/G-Core/gcore-storage-sdk-go v0.1.34 h1:0GPQfz1kA6mQi6fiisGsh0Um4H9PZeHWIPsc825cDrY=
github.com/G-Core/gcore-storage-sdk-go v0.1.34/go.mod h1:BUAEZZZJJt/+luRFunqziv3+JnbVMLbQXDWz9kV8Te8=
github.com/G-Core/gcorelabscdn-go v0.1.26 h1:uWuXSVyPzhg3NoROXADDx+Nhsq20DN8Sh1pBR0GcxMo=
github.com/G-Core/gcorelabscdn-go v0.1.26/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscdn-go v0.1.27 h1:ZekODS/la0tA24fpW5jvpCK0TA2gGCJvn/fCXgbQ3YI=
github.com/G-Core/gcorelabscdn-go v0.1.27/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscloud-go v0.5.31 h1:cbGJVaBf4zUK/CXM8rKEGhfl68sq4QJpGwEwmAM4tV4=
Expand Down

0 comments on commit bc73b5b

Please sign in to comment.