Skip to content

Commit

Permalink
fix integration tests after terraform sdk upgrade to 0.12
Browse files Browse the repository at this point in the history
- endpoints is now using blocks
- errors are formatted slightly differently
- arrays of objects are now configured as multiple blocks using the same
identifier
  • Loading branch information
dikhan committed May 29, 2019
1 parent 9d5cf43 commit f0ef546
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
53 changes: 26 additions & 27 deletions tests/integration/resource_cdns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestAccCDN_CreateJustRequired(t *testing.T) {
config := fmt.Sprintf(`provider "%s" {
apikey_auth = "apiKeyValue"
x_request_id = "some value..."
endpoints = {}
endpoints {}
}
resource "%s" "%s" {
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestAccCDN_Create_EndPointOverride(t *testing.T) {
testCreateConfigCDNWithResourceEndpointOverride := fmt.Sprintf(`provider "%s" {
apikey_auth = "apiKeyValue"
x_request_id = "some value..."
endpoints = {
endpoints {
%s = "%s" # this effectively overrides the default endpoint for 'cdn_v1', and API calls will be made against the value for this property
}
}
Expand All @@ -197,7 +197,7 @@ resource "%s" "%s" {
ips = ["0.0.0.0"]
hostnames = ["www.hostname.com"]
}`, providerName, resourceCDNName, endpoint, openAPIResourceNameCDN, openAPIResourceInstanceNameCDN)
expectedValidationError, _ := regexp.Compile(".*openapi_cdn_v1.my_cdn: unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://www\\.endpoint\\.com/v1/cdns HTTP/1\\.1'. Response = '404 Not Found'.*")
expectedValidationError, _ := regexp.Compile(".*unable to unmarshal response body \\['invalid character '<' looking for beginning of value'\\] for request = 'POST https://www\\.endpoint\\.com/v1/cdns HTTP/1\\.1'. Response = '404 Not Found'.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down Expand Up @@ -379,7 +379,7 @@ func TestAccCDN_CreateFailsDueToMissingMandatoryApiKeyAuth(t *testing.T) {
}
resource "%s" "my_cdn" {}`, providerName, openAPIResourceNameCDN)

expectedValidationError, _ := regexp.Compile(".*\"apikey_auth\": required field is not set.*")
expectedValidationError, _ := regexp.Compile(".*config is invalid: Missing required argument: The argument \"apikey_auth\" is required, but no definition was found.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down Expand Up @@ -429,7 +429,7 @@ resource "%s" "my_cdn" {
hostnames = ["%s"]
}`, providerName, openAPIResourceNameCDN, cdn.Label, arrayToString(cdn.Ips), arrayToString(cdn.Hostnames))

expectedValidationError, _ := regexp.Compile(".*\"label\": required field is not set.*")
expectedValidationError, _ := regexp.Compile(".*config is invalid: Missing required argument: The argument \"label\" is required, but no definition was found.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down Expand Up @@ -806,7 +806,7 @@ func populateTemplateConfigurationCDN(label string, ips, hostnames []string, exa
return fmt.Sprintf(`provider "%s" {
apikey_auth = "apiKeyValue"
x_request_id = "some value..."
endpoints = {}
endpoints {}
}
resource "%s" "%s" {
Expand All @@ -826,24 +826,23 @@ resource "%s" "%s" {
example_boolean = %v
}
array_of_objects_example = [
{
protocol = "%s"
origin_port = %d
},
{
protocol = "%s"
origin_port = %d
}
]
array_of_objects_example {
protocol = "%s"
origin_port = %d
}
array_of_objects_example {
protocol = "%s"
origin_port = %d
}
}`, providerName, openAPIResourceNameCDN, openAPIResourceInstanceNameCDN, label, arrayToString(ips), arrayToString(hostnames), exampleInt, floatToString(exampleNumber), exampleBool, objectPropertyMessage, objectDetailedMessage, exampleInt, floatToString(exampleNumber), exampleBool, listObjectProtocol, listObjectOriginPort, listObject2Protocol, listObject2OriginPort)
}

func populateTemplateConfigurationCDNWithOptionalsPopulated(label string, ips, hostnames []string, exampleInt int32, exampleNumber float32, exampleBool bool, objectPropertyMessage, objectDetailedMessage, listObjectProtocol string, listObjectOriginPort int32, listObject2Protocol string, listObject2OriginPort int32, optionalProperty, optionalComputed, optionalComputedWithDefault string) string {
return fmt.Sprintf(`provider "%s" {
apikey_auth = "apiKeyValue"
x_request_id = "some value..."
endpoints = {}
endpoints {}
}
resource "%s" "%s" {
Expand All @@ -867,16 +866,16 @@ resource "%s" "%s" {
example_boolean = %v
}
array_of_objects_example = [
{
protocol = "%s"
origin_port = %d
},
{
protocol = "%s"
origin_port = %d
}
]
array_of_objects_example {
protocol = "%s"
origin_port = %d
}
array_of_objects_example {
protocol = "%s"
origin_port = %d
}
}`, providerName, openAPIResourceNameCDN, openAPIResourceInstanceNameCDN, label, arrayToString(ips), arrayToString(hostnames), optionalProperty, optionalComputed, optionalComputedWithDefault, exampleInt, floatToString(exampleNumber), exampleBool, objectPropertyMessage, objectDetailedMessage, exampleInt, floatToString(exampleNumber), exampleBool, listObjectProtocol, listObjectOriginPort, listObject2Protocol, listObject2OriginPort)
}

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(".*openapi_monitors_v1_rst1.my_monitor: 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(".*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'.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -41,7 +41,7 @@ func TestAccMonitor_CreateRst1(t *testing.T) {
}

func TestAccMonitor_CreateDub1(t *testing.T) {
expectedValidationError, _ := regexp.Compile(".*openapi_monitors_v1_dub1.my_monitor: 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(".*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'.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: 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(".*openapi_multiregionmonitors_v1.my_monitor: 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(".*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'.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: 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(".*openapi_multiregionmonitors_v1.my_monitor: 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(".*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'.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -101,7 +101,7 @@ resource "openapi_multiregionmonitors_v1" "%s" {
name = "someName"
}`, providerName, openAPIResourceInstanceNameMonitor)

expectedValidationError, _ := regexp.Compile(".*openapi_multiregionmonitors_v1.my_monitor: 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(".*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'.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down

0 comments on commit f0ef546

Please sign in to comment.