diff --git a/openapi/openapi_v2_spec_analyser_test.go b/openapi/openapi_v2_spec_analyser_test.go index 816366dbd..6577701c3 100644 --- a/openapi/openapi_v2_spec_analyser_test.go +++ b/openapi/openapi_v2_spec_analyser_test.go @@ -1651,7 +1651,7 @@ func TestNewSpecAnalyserV2(t *testing.T) { }) Convey("Given a swagger doc with a circular ref (ref points to itself)", t, func() { - var swaggerJSON = fmt.Sprintf(`{ + var swaggerJSON = `{ "swagger":"2.0", "paths":{ "/v1/cdns":{ @@ -1675,7 +1675,7 @@ func TestNewSpecAnalyserV2(t *testing.T) { "$ref":"#/definitions/ContentDeliveryNetwork" } } -}`) +}` swaggerFile := initAPISpecFile(swaggerJSON) defer os.Remove(swaggerFile.Name()) Convey("When newSpecAnalyserV2 method is called", func() { @@ -1697,7 +1697,7 @@ func TestNewSpecAnalyserV2(t *testing.T) { }) Convey("Given a swagger doc with a ref to a definition that does not exists", t, func() { - var swaggerJSON = fmt.Sprintf(`{ + var swaggerJSON = `{ "swagger":"2.0", "paths":{ "/v1/cdns":{ @@ -1716,7 +1716,7 @@ func TestNewSpecAnalyserV2(t *testing.T) { } } } -}`) +}` swaggerFile := initAPISpecFile(swaggerJSON) defer os.Remove(swaggerFile.Name()) Convey("When newSpecAnalyserV2 method is called", func() { @@ -1729,7 +1729,7 @@ func TestNewSpecAnalyserV2(t *testing.T) { }) Convey("Given a swagger doc with a ref to a definition is wrongly formatted (no empty string)", t, func() { - var swaggerJSON = fmt.Sprintf(`{ + var swaggerJSON = `{ "swagger":"2.0", "paths":{ "/v1/cdns":{ @@ -1748,7 +1748,7 @@ func TestNewSpecAnalyserV2(t *testing.T) { } } } -}`) +}` swaggerFile := initAPISpecFile(swaggerJSON) defer os.Remove(swaggerFile.Name()) Convey("When newSpecAnalyserV2 method is called", func() { diff --git a/openapi/plugin_config_test.go b/openapi/plugin_config_test.go index 221cdd458..d14c6335f 100644 --- a/openapi/plugin_config_test.go +++ b/openapi/plugin_config_test.go @@ -94,7 +94,7 @@ func TestGetServiceProviderConfiguration(t *testing.T) { os.Unsetenv(otfVarNameUc) }) - Convey(fmt.Sprintf("Given a PluginConfiguration for 'test' provider and a OTF_VAR_test_SWAGGER_URL env variable is not set"), t, func() { + Convey("Given a PluginConfiguration for 'test' provider and a OTF_VAR_test_SWAGGER_URL env variable is not set", t, func() { pluginConfiguration, _ := NewPluginConfiguration(providerName) Convey("When getServiceConfiguration is called", func() { _, err := pluginConfiguration.getServiceConfiguration() @@ -215,10 +215,10 @@ services: }) Convey("Given a PluginConfiguration for 'test' provider and a plugin configuration that DOES NOT contain a service called 'test'", t, func() { - pluginConfig := fmt.Sprintf(`version: '1' + pluginConfig := `version: '1' services: some-other-service: - swagger-url: http://some-other-service-api/swagger.yaml`) + swagger-url: http://some-other-service-api/swagger.yaml` configReader := strings.NewReader(pluginConfig) pluginConfiguration := PluginConfiguration{ ProviderName: providerName, diff --git a/tests/e2e/gray_box_plugin_test.go b/tests/e2e/gray_box_plugin_test.go index 3e5d8a83e..19994e985 100644 --- a/tests/e2e/gray_box_plugin_test.go +++ b/tests/e2e/gray_box_plugin_test.go @@ -117,10 +117,10 @@ definitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(` + tfFileContents := ` resource "openapi_cdn_v1" "my_cdn_v1" { label = "my_label" -}`) +}` resource.Test(t, resource.TestCase{ IsUnitTest: true, diff --git a/tests/e2e/provider_plugin_configuration_test.go b/tests/e2e/provider_plugin_configuration_test.go index cf2f70544..f2c259a2e 100644 --- a/tests/e2e/provider_plugin_configuration_test.go +++ b/tests/e2e/provider_plugin_configuration_test.go @@ -154,7 +154,7 @@ services: PreCheck: func() { testAccPreCheck(t, swaggerServer.URL) }, Steps: []resource.TestStep{ { - Config: fmt.Sprintf(` + Config: ` provider "openapi" { some_token = "token_value" some_header = "header_value" @@ -172,7 +172,7 @@ data "openapi_cdns_v1" "my_data_cdn" { data "openapi_cdns_v1_instance" "my_cdn" { id = "someID" -}`), +}`, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "openapi_cdns_v1.my_cdn", "label", "some_label"), @@ -328,7 +328,7 @@ services: PreCheck: func() { testAccPreCheck(t, swaggerServer.URL) }, Steps: []resource.TestStep{ { - Config: fmt.Sprintf(`resource "openapi_cdns_v1" "my_cdn" { label = "some_label"}`), + Config: `resource "openapi_cdns_v1" "my_cdn" { label = "some_label"}`, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "openapi_cdns_v1.my_cdn", "label", "some_label"), diff --git a/tests/e2e/resources_test.go b/tests/e2e/resources_test.go index 239b283e9..0476ff039 100644 --- a/tests/e2e/resources_test.go +++ b/tests/e2e/resources_test.go @@ -76,14 +76,14 @@ definitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(` + tfFileContents := ` provider "openapi" { required_header_example = "" } resource "openapi_cdns" "my_cdn" { label = "some label" -}`) +}` expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required header 'required_header_example' is missing the value. Please make sure the property 'required_header_example' is configured with a value in the provider's terraform configuration.*") resource.Test(t, resource.TestCase{ @@ -165,13 +165,13 @@ securityDefinitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(` + tfFileContents := ` provider "openapi" { some_not_global_sec_def = "" } resource "openapi_cdns" "my_cdn" { label = "some label" -}`) +}` expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required security definition 'some_not_global_sec_def' is missing the value. Please make sure the property 'some_not_global_sec_def' is configured with a value in the provider's terraform configuration.*") resource.Test(t, resource.TestCase{ @@ -253,13 +253,13 @@ securityDefinitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(` + tfFileContents := ` provider "openapi" { some_not_global_sec_def = "" } resource "openapi_cdns" "my_cdn" { label = "some label" -}`) +}` expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required security definition 'some_not_global_sec_def' is missing the value. Please make sure the property 'some_not_global_sec_def' is configured with a value in the provider's terraform configuration.*") resource.Test(t, resource.TestCase{ @@ -342,13 +342,13 @@ securityDefinitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(` + tfFileContents := ` provider "openapi" { some_not_global_sec_def = "" } resource "openapi_cdns" "my_cdn" { label = "some label" -}`) +}` expectedValidationError, _ := regexp.Compile(".*failed to configure the API request for POST http://127.0.0.1:[\\d]+/cdns: required security definition 'some_not_global_sec_def' is missing the value. Please make sure the property 'some_not_global_sec_def' is configured with a value in the provider's terraform configuration.*") resource.Test(t, resource.TestCase{ @@ -431,7 +431,7 @@ definitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(`resource "openapi_deploykey_v1" "my_deploykeyv1" {}`) + tfFileContents := `resource "openapi_deploykey_v1" "my_deploykeyv1" {}` resource.Test(t, resource.TestCase{ IsUnitTest: true, @@ -519,7 +519,7 @@ definitions: }) assert.NoError(t, err) - tfFileContents := fmt.Sprintf(`resource "openapi_deploykey_v1" "my_deploykeyv1" {}`) + tfFileContents := `resource "openapi_deploykey_v1" "my_deploykeyv1" {}` resource.Test(t, resource.TestCase{ IsUnitTest: true, diff --git a/tests/integration/provider_plugin_configuration_test.go b/tests/integration/provider_plugin_configuration_test.go index 13e267219..613d0de93 100644 --- a/tests/integration/provider_plugin_configuration_test.go +++ b/tests/integration/provider_plugin_configuration_test.go @@ -69,14 +69,14 @@ resource "%s" "my_cdn" { } func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_DefaultValue(t *testing.T) { - testPluginConfig := fmt.Sprintf(`version: '1' + testPluginConfig := `version: '1' services: openapi: swagger-url: https://localhost:8443/swagger.yaml insecure_skip_verify: true schema_configuration: - schema_property_name: "apikey_auth" - default_value: "apiKeyValue"`) + default_value: "apiKeyValue"` file := createPluginConfigFile(testPluginConfig) defer os.Remove(file.Name()) resource.Test(t, resource.TestCase{ @@ -254,14 +254,14 @@ services: } func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_ExternalConfiguration_With_Non_Successful_Command(t *testing.T) { - testPluginConfig := fmt.Sprintf(`version: '1' + testPluginConfig := `version: '1' services: openapi: swagger-url: https://localhost:8443/swagger.yaml insecure_skip_verify: true schema_configuration: - schema_property_name: "apikey_auth" - cmd: ["cat", "nonExistingFile"]`) + cmd: ["cat", "nonExistingFile"]` file := createPluginConfigFile(testPluginConfig) defer os.Remove(file.Name()) initPluginWithExternalConfigFile(file.Name()) @@ -273,7 +273,7 @@ services: } func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_ExternalConfiguration_With_Command_With_Timeout(t *testing.T) { - testPluginConfig := fmt.Sprintf(`version: '1' + testPluginConfig := `version: '1' services: openapi: swagger-url: https://localhost:8443/swagger.yaml @@ -281,7 +281,7 @@ services: schema_configuration: - schema_property_name: "apikey_auth" cmd: ["sleep", "2"] - cmd_timeout: 1`) + cmd_timeout: 1` file := createPluginConfigFile(testPluginConfig) defer os.Remove(file.Name()) initPluginWithExternalConfigFile(file.Name()) @@ -292,7 +292,7 @@ services: } func TestAccProviderConfiguration_PluginExternalFile_SchemaProperty_ExternalConfiguration_FileNotExists(t *testing.T) { - testPluginConfig := fmt.Sprintf(`version: '1' + testPluginConfig := `version: '1' services: openapi: swagger-url: https://localhost:8443/swagger.yaml @@ -303,7 +303,7 @@ services: schema_property_external_configuration: content_type: json key_name: $.apikey_auth - file: /path_to_non_existing_file.json`) + file: /path_to_non_existing_file.json` file := createPluginConfigFile(testPluginConfig) defer os.Remove(file.Name()) initPluginWithExternalConfigFile(file.Name())