|
7 | 7 | "testing" |
8 | 8 |
|
9 | 9 | "github.com/stretchr/testify/assert" |
| 10 | + "github.com/stretchr/testify/require" |
10 | 11 | "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common" |
11 | 12 | "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper" |
12 | 13 | "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic" |
@@ -164,11 +165,21 @@ func TestRunBuildExampleInSchematics(t *testing.T) { |
164 | 165 | DeleteWorkspaceOnFail: false, |
165 | 166 | WaitJobCompleteMinutes: 60, |
166 | 167 | }) |
| 168 | + |
| 169 | + // Verify ibmcloud_api_key variable is set |
| 170 | + checkVariable := "TF_VAR_ibmcloud_api_key" |
| 171 | + val, present := os.LookupEnv(checkVariable) |
| 172 | + require.True(t, present, checkVariable+" environment variable not set") |
| 173 | + require.NotEqual(t, "", val, checkVariable+" environment variable is empty") |
| 174 | + |
| 175 | + // Programmatically determine region to use based on availability |
| 176 | + region, _ := testhelper.GetBestVpcRegion(val, "../common-dev-assets/common-go-assets/cloudinfo-region-vpc-gen2-prefs.yaml", "eu-de") |
| 177 | + |
167 | 178 | options.TerraformVars = []testschematic.TestSchematicTerraformVar{ |
168 | 179 | {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, |
169 | 180 | {Name: "resource_group", Value: options.ResourceGroup, DataType: "string"}, |
170 | 181 | {Name: "prefix", Value: options.Prefix + "-b", DataType: "string"}, |
171 | | - {Name: "region", Value: options.Region, DataType: "string"}, |
| 182 | + {Name: "region", Value: region, DataType: "string"}, |
172 | 183 | } |
173 | 184 |
|
174 | 185 | err := options.RunSchematicTest() |
|
0 commit comments