|
7 | 7 |
|
8 | 8 | "github.com/stretchr/testify/assert" |
9 | 9 | "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper" |
| 10 | + "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic" |
10 | 11 | ) |
11 | 12 |
|
12 | 13 | // Use existing resource group |
@@ -51,27 +52,67 @@ func TestRunBasicExample(t *testing.T) { |
51 | 52 | assert.NotNil(t, output, "Expected some output") |
52 | 53 | } |
53 | 54 |
|
54 | | -func TestRunAdvancedExample(t *testing.T) { |
| 55 | +func TestRunAdvancedExampleInSchematics(t *testing.T) { |
55 | 56 | // https://github.ibm.com/GoldenEye/issues/issues/12223 |
56 | 57 | // Avoid t.Parallel() to avoid test clashes |
57 | 58 |
|
58 | | - options := setupOptions(t, "icm-adv", advancedExampleDir) |
| 59 | + var region = validRegions[rand.Intn(len(validRegions))] |
59 | 60 |
|
60 | | - output, err := options.RunTestConsistency() |
| 61 | + options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ |
| 62 | + Testing: t, |
| 63 | + Prefix: "icm-adv", |
| 64 | + TarIncludePatterns: []string{ |
| 65 | + "*.tf", |
| 66 | + "modules/metrics_routing" + "/*.tf", |
| 67 | + advancedExampleDir + "/*.tf", |
| 68 | + }, |
| 69 | + ResourceGroup: resourceGroup, |
| 70 | + TemplateFolder: advancedExampleDir, |
| 71 | + Tags: []string{"test-schematic"}, |
| 72 | + DeleteWorkspaceOnFail: false, |
| 73 | + WaitJobCompleteMinutes: 60, |
| 74 | + }) |
| 75 | + |
| 76 | + options.TerraformVars = []testschematic.TestSchematicTerraformVar{ |
| 77 | + {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, |
| 78 | + {Name: "prefix", Value: options.Prefix, DataType: "string"}, |
| 79 | + {Name: "region", Value: region, DataType: "string"}, |
| 80 | + } |
| 81 | + |
| 82 | + err := options.RunSchematicTest() |
61 | 83 | assert.Nil(t, err, "This should not have errored") |
62 | | - assert.NotNil(t, output, "Expected some output") |
63 | 84 | } |
64 | 85 |
|
65 | | -// Upgrade test (using advanced example) |
66 | | -func TestRunUpgradeExample(t *testing.T) { |
| 86 | +// Upgrade test in schematics (using advanced example) |
| 87 | +func TestRunUpgradeExampleInSchematics(t *testing.T) { |
67 | 88 | // https://github.ibm.com/GoldenEye/issues/issues/12223 |
68 | 89 | // Avoid t.Parallel() to avoid test clashes |
69 | 90 |
|
70 | | - options := setupOptions(t, "icm-adv-upg", advancedExampleDir) |
| 91 | + var region = validRegions[rand.Intn(len(validRegions))] |
| 92 | + |
| 93 | + options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ |
| 94 | + Testing: t, |
| 95 | + Prefix: "icm-adv-upg", |
| 96 | + TarIncludePatterns: []string{ |
| 97 | + "*.tf", |
| 98 | + "modules/metrics_routing" + "/*.tf", |
| 99 | + advancedExampleDir + "/*.tf", |
| 100 | + }, |
| 101 | + ResourceGroup: resourceGroup, |
| 102 | + TemplateFolder: advancedExampleDir, |
| 103 | + Tags: []string{"test-schematic"}, |
| 104 | + DeleteWorkspaceOnFail: false, |
| 105 | + WaitJobCompleteMinutes: 60, |
| 106 | + }) |
| 107 | + |
| 108 | + options.TerraformVars = []testschematic.TestSchematicTerraformVar{ |
| 109 | + {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, |
| 110 | + {Name: "prefix", Value: options.Prefix, DataType: "string"}, |
| 111 | + {Name: "region", Value: region, DataType: "string"}, |
| 112 | + } |
71 | 113 |
|
72 | | - output, err := options.RunTestUpgrade() |
| 114 | + err := options.RunSchematicUpgradeTest() |
73 | 115 | if !options.UpgradeTestSkipped { |
74 | 116 | assert.Nil(t, err, "This should not have errored") |
75 | | - assert.NotNil(t, output, "Expected some output") |
76 | 117 | } |
77 | 118 | } |
0 commit comments