Skip to content

Commit

Permalink
Fix monitor int tests assertions that before were actually resolving …
Browse files Browse the repository at this point in the history
…to an actual domain

- The monitor int tests rely on the error output to confirm the API call was made
against the right reginal endpoint
  • Loading branch information
dikhan committed Jul 14, 2021
1 parent f0f7cf4 commit 237d338
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/swaggercodegen/api/resources/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ security:
# This make the provider multiregional, so API calls will be make against the specific region as per the value provided
# provided by the user according to the 'x-terraform-provider-regions' regions. If non is provided, the default value will
# be the first item in the 'x-terraform-provider-regions' list of strings. in the case below that will be 'rst1'
x-terraform-provider-multiregion-fqdn: "some.api.${region}.domain.com"
x-terraform-provider-multiregion-fqdn: "some.api.${region}.nonexistingrandomdomain.io" # Making it a bit more random to avoid resolving to an actual existing domain
x-terraform-provider-regions: "rst1,dub1"

# This is legacy configuration that will be deprecated soon
Expand Down Expand Up @@ -348,7 +348,7 @@ paths:
- "monitor"
summary: "Create monitor v1"
operationId: "CreateMonitorV1"
x-terraform-resource-host: "some.api.${monitor}.domain.com"
x-terraform-resource-host: "some.api.${monitor}.nonexistingrandomdomain.io" # Making it a bit more random to avoid resolving to an actual existing domain
parameters:
- in: "body"
name: "body"
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/resource_monitors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func init() {
}

func TestAccMonitor_CreateRst1(t *testing.T) {
expectedValidationError, _ := regexp.Compile(".*unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://some\\.api\\.rst1\\.domain\\.com/v1/monitors HTTP/1\\.1'\\. Response = '404 Not Found'.*")
expectedValidationError, _ := regexp.Compile(".*request POST https://some.api.rst1.nonexistingrandomdomain.io/v1/monitors HTTP/1.1 failed. Response Error: 'Post \"https://some.api.rst1.nonexistingrandomdomain.io/v1/monitors\": dial tcp: lookup some.api.rst1.nonexistingrandomdomain.io.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
Expand All @@ -41,7 +41,7 @@ func TestAccMonitor_CreateRst1(t *testing.T) {
}

func TestAccMonitor_CreateDub1(t *testing.T) {
expectedValidationError, _ := regexp.Compile(".*unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://some\\.api\\.dub1\\.domain\\.com/v1/monitors HTTP/1\\.1'\\. Response = '404 Not Found'.*")
expectedValidationError, _ := regexp.Compile(".*request POST https://some.api.dub1.nonexistingrandomdomain.io/v1/monitors HTTP/1.1 failed. Response Error: 'Post \"https://some.api.dub1.nonexistingrandomdomain.io/v1/monitors\": dial tcp: lookup some.api.dub1.nonexistingrandomdomain.io.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
Expand All @@ -58,7 +58,7 @@ func TestAccMonitor_CreateDub1(t *testing.T) {

func TestAccMonitor_MultiRegion_CreateRst1(t *testing.T) {
testCreateConfigMonitor = populateTemplateConfigurationMonitorServiceProvider("rst1")
expectedValidationError, _ := regexp.Compile(".*unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://some\\.api\\.rst1\\.domain\\.com/v1/multiregionmonitors HTTP/1\\.1'\\. Response = '404 Not Found'.*")
expectedValidationError, _ := regexp.Compile(".*request POST https://some.api.rst1.nonexistingrandomdomain.io/v1/multiregionmonitors HTTP/1.1 failed. Response Error: 'Post \"https://some.api.rst1.nonexistingrandomdomain.io/v1/multiregionmonitors\": dial tcp: lookup some.api.rst1.nonexistingrandomdomain.io.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
Expand All @@ -75,7 +75,7 @@ func TestAccMonitor_MultiRegion_CreateRst1(t *testing.T) {

func TestAccMonitor_MultiRegion_CreateDub1(t *testing.T) {
testCreateConfigMonitor = populateTemplateConfigurationMonitorServiceProvider("dub1")
expectedValidationError, _ := regexp.Compile(".*unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://some\\.api\\.dub1\\.domain\\.com/v1/multiregionmonitors HTTP/1\\.1'\\. Response = '404 Not Found'.*")
expectedValidationError, _ := regexp.Compile(".*request POST https://some.api.dub1.nonexistingrandomdomain.io/v1/multiregionmonitors HTTP/1.1 failed. Response Error: 'Post \"https://some.api.dub1.nonexistingrandomdomain.io/v1/multiregionmonitors\": dial tcp: lookup some.api.dub1.nonexistingrandomdomain.io.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
Expand All @@ -101,7 +101,7 @@ resource "openapi_multiregionmonitors_v1" "%s" {
name = "someName"
}`, providerName, openAPIResourceInstanceNameMonitor)

expectedValidationError, _ := regexp.Compile(".*unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://some\\.api\\.rst1\\.domain\\.com/v1/multiregionmonitors HTTP/1\\.1'\\. Response = '404 Not Found'.*")
expectedValidationError, _ := regexp.Compile(".*request POST https://some.api.rst1.nonexistingrandomdomain.io/v1/multiregionmonitors HTTP/1.1 failed. Response Error: 'Post \"https://some.api.rst1.nonexistingrandomdomain.io/v1/multiregionmonitors\": dial tcp: lookup some.api.rst1.nonexistingrandomdomain.io.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
Expand Down

0 comments on commit 237d338

Please sign in to comment.