Skip to content

Commit ba72e7c

Browse files
authored
test: added addon testing (#80)
1 parent 39ee1dd commit ba72e7c

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

tests/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.25.0
77
require (
88
github.com/gruntwork-io/terratest v0.50.0
99
github.com/stretchr/testify v1.10.0
10-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.59.1
10+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.59.7
1111
)
1212

1313
require (

tests/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
295295
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
296296
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
297297
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
298-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.59.1 h1:9/uYvUFFLIH91F16AiJqP/LZeGi4t2CYtc8iz3bBXdQ=
299-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.59.1/go.mod h1:kdhZ+FeS71D+tB0E2Sh1ISD3zQ+RThPX5SyFqduo7G8=
298+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.59.7 h1:HyrZbLB+7dv9Fspe2wvnCe1IYMC6K6AQcoaktQf30j0=
299+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.59.7/go.mod h1:kdhZ+FeS71D+tB0E2Sh1ISD3zQ+RThPX5SyFqduo7G8=
300300
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
301301
github.com/tmccombs/hcl2json v0.6.4 h1:/FWnzS9JCuyZ4MNwrG4vMrFrzRgsWEOVi+1AyYUVLGw=
302302
github.com/tmccombs/hcl2json v0.6.4/go.mod h1:+ppKlIW3H5nsAsZddXPy2iMyvld3SHxyjswOZhavRDk=

tests/pr_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414
"github.com/gruntwork-io/terratest/modules/terraform"
1515
"github.com/stretchr/testify/assert"
1616
"github.com/stretchr/testify/require"
17+
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
1718
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
19+
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons"
1820
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
1921
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
2022
)
@@ -219,3 +221,48 @@ func TestRunAccountSettings(t *testing.T) {
219221
err := options.RunSchematicTest()
220222
assert.Nil(t, err, "This should not have errored")
221223
}
224+
225+
func TestAddonDefaultConfiguration(t *testing.T) {
226+
t.Parallel()
227+
228+
options := testaddons.TestAddonsOptionsDefault(&testaddons.TestAddonOptions{
229+
Testing: t,
230+
Prefix: "icm-def",
231+
ResourceGroup: resourceGroup,
232+
QuietMode: true, // Suppress logs except on failure
233+
})
234+
235+
options.AddonConfig = cloudinfo.NewAddonConfigTerraform(
236+
options.Prefix,
237+
"deploy-arch-ibm-cloud-monitoring",
238+
"fully-configurable",
239+
map[string]interface{}{
240+
"prefix": options.Prefix,
241+
"region": validRegions[rand.Intn(len(validRegions))],
242+
},
243+
)
244+
245+
err := options.RunAddonTest()
246+
require.NoError(t, err)
247+
}
248+
249+
// TestDependencyPermutations runs dependency permutations for Cloud Monitoring and all its dependencies
250+
func TestDependencyPermutations(t *testing.T) {
251+
t.Parallel()
252+
253+
options := testaddons.TestAddonsOptionsDefault(&testaddons.TestAddonOptions{
254+
Testing: t,
255+
Prefix: "icm-per",
256+
AddonConfig: cloudinfo.AddonConfig{
257+
OfferingName: "deploy-arch-ibm-cloud-monitoring",
258+
OfferingFlavor: "fully-configurable",
259+
Inputs: map[string]interface{}{
260+
"prefix": "icm-per",
261+
"region": validRegions[rand.Intn(len(validRegions))],
262+
},
263+
},
264+
})
265+
266+
err := options.RunAddonPermutationTest()
267+
assert.NoError(t, err, "Dependency permutation test should not fail")
268+
}

0 commit comments

Comments
 (0)