generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(resource): fix schema and add tests for resource provider (#339)
The schema for the resource provider resource and datasources is fixed and corresponding tests are added. Furthermore, some attribute names were improved. Resolves #337
- Loading branch information
Showing
14 changed files
with
3,161 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
internal/provider/datasource_globalaccount_resource_provider_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package provider | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
func TestDataSourceGlobalaccountResourceProvider(t *testing.T) { | ||
t.Parallel() | ||
t.Run("happy path", func(t *testing.T) { | ||
rec := setupVCR(t, "fixtures/datasource_globalaccount_resource_provider") | ||
defer stopQuietly(rec) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
IsUnitTest: true, | ||
ProtoV6ProviderFactories: getProviders(rec.GetDefaultClient()), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: hclProvider() + hclDatasourceGlobalaccountResourceProvider("uut", | ||
"AWS", | ||
"tf_test_resource_provider"), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.btp_globalaccount_resource_provider.uut", "provider_type", "AWS"), | ||
resource.TestCheckResourceAttr("data.btp_globalaccount_resource_provider.uut", "technical_name", "tf_test_resource_provider"), | ||
resource.TestCheckResourceAttr("data.btp_globalaccount_resource_provider.uut", "id", "tf_test_resource_provider"), | ||
resource.TestCheckResourceAttr("data.btp_globalaccount_resource_provider.uut", "display_name", "Test AWS Resource Provider"), | ||
resource.TestCheckResourceAttr("data.btp_globalaccount_resource_provider.uut", "description", "Description of the resource provider"), | ||
resource.TestCheckResourceAttr("data.btp_globalaccount_resource_provider.uut", "configuration", "{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"eu-central-1\"}"), | ||
), | ||
}, | ||
}, | ||
}) | ||
}) | ||
} | ||
|
||
func hclDatasourceGlobalaccountResourceProvider(resourceName string, provider string, technicalName string) string { | ||
return fmt.Sprintf(` | ||
data "btp_globalaccount_resource_provider" "%s" { | ||
provider_type = "%s" | ||
technical_name = "%s" | ||
}`, resourceName, provider, technicalName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.