99 "github.com/stretchr/testify/assert"
1010 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
1111 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
12+ "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
1213)
1314
1415// Define a struct with fields that match the structure of the YAML data
@@ -21,6 +22,7 @@ const resourceGroup = "geretain-test-sm-pub-cert-eng"
2122
2223const keyExampleTerraformDir = "examples/api_key_auth"
2324const IAMExampleTerraformDir = "examples/iam_auth"
25+ const bestRegionYAMLPath = "../common-dev-assets/common-go-assets/cloudinfo-region-secmgr-prefs.yaml"
2426
2527// TestMain will be run before any parallel tests, used to read data from yaml for use with tests
2628func TestMain (m * testing.M ) {
@@ -45,20 +47,43 @@ func setupOptions(t *testing.T, prefix string, dir string) *testhelper.TestOptio
4547 "private_key_secrets_manager_secret_id" : permanentResources ["acme_letsencrypt_private_key_secret_id" ],
4648 "private_key_secrets_manager_region" : permanentResources ["acme_letsencrypt_private_key_sm_region" ],
4749 },
48- BestRegionYAMLPath : "../common-dev-assets/common-go-assets/cloudinfo-region-secmgr-prefs.yaml" ,
50+ BestRegionYAMLPath : bestRegionYAMLPath ,
4951 })
5052
5153 return options
5254}
5355
54- func TestRunAPIKeyExample (t * testing.T ) {
56+ func TestPrivateInSchematics (t * testing.T ) {
5557 t .Parallel ()
5658
57- options := setupOptions (t , "sm-public-cert-eng" , keyExampleTerraformDir )
59+ options := testschematic .TestSchematicOptionsDefault (& testschematic.TestSchematicOptions {
60+ Testing : t ,
61+ Prefix : "sm-pub-crt-eng-prv" ,
62+ TarIncludePatterns : []string {
63+ "*.tf" ,
64+ keyExampleTerraformDir + "/*.tf" ,
65+ },
66+ ResourceGroup : resourceGroup ,
67+ TemplateFolder : keyExampleTerraformDir ,
68+ Tags : []string {"test-schematic" },
69+ DeleteWorkspaceOnFail : false ,
70+ WaitJobCompleteMinutes : 80 ,
71+ BestRegionYAMLPath : bestRegionYAMLPath ,
72+ })
5873
59- output , err := options .RunTestConsistency ()
74+ options .TerraformVars = []testschematic.TestSchematicTerraformVar {
75+ {Name : "ibmcloud_api_key" , Value : options .RequiredEnvironmentVars ["TF_VAR_ibmcloud_api_key" ], DataType : "string" , Secure : true },
76+ {Name : "resource_tags" , Value : options .Tags , DataType : "list(string)" },
77+ {Name : "region" , Value : options .Region , DataType : "string" },
78+ {Name : "prefix" , Value : options .Prefix , DataType : "string" },
79+ {Name : "cis_id" , Value : permanentResources ["cisInstanceId" ], DataType : "string" },
80+ {Name : "private_key_secrets_manager_instance_guid" , Value : permanentResources ["acme_letsencrypt_private_key_sm_id" ], DataType : "string" },
81+ {Name : "private_key_secrets_manager_secret_id" , Value : permanentResources ["acme_letsencrypt_private_key_secret_id" ], DataType : "string" },
82+ {Name : "private_key_secrets_manager_region" , Value : permanentResources ["acme_letsencrypt_private_key_sm_region" ], DataType : "string" },
83+ }
84+
85+ err := options .RunSchematicTest ()
6086 assert .Nil (t , err , "This should not have errored" )
61- assert .NotNil (t , output , "Expected some output" )
6287}
6388
6489func TestRunIAMExample (t * testing.T ) {
0 commit comments