Skip to content

Commit 2f87a65

Browse files
authored
test: Add override test (#563)
1 parent b835988 commit 2f87a65

File tree

3 files changed

+101
-30
lines changed

3 files changed

+101
-30
lines changed

tests/go.mod

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ module github.com/terraform-ibm-modules/terraform-ibm-landing-zone
33
go 1.20
44

55
require (
6+
github.com/gruntwork-io/terratest v0.43.13
67
github.com/stretchr/testify v1.8.4
7-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.21.4
8+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.21.7
89
)
910

1011
require (
@@ -17,23 +18,24 @@ require (
1718
github.com/IBM-Cloud/bluemix-go v0.0.0-20230616121711-b838ccdcd2fb // indirect
1819
github.com/IBM-Cloud/power-go-client v1.3.1 // indirect
1920
github.com/IBM/go-sdk-core/v5 v5.14.1 // indirect
20-
github.com/IBM/platform-services-go-sdk v0.48.1 // indirect
21+
github.com/IBM/platform-services-go-sdk v0.49.0 // indirect
2122
github.com/IBM/vpc-go-sdk v1.0.2 // indirect
2223
github.com/Microsoft/go-winio v0.6.1 // indirect
23-
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
24+
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
2425
github.com/acomagu/bufpipe v1.0.4 // indirect
2526
github.com/agext/levenshtein v1.2.3 // indirect
2627
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
2728
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
2829
github.com/aws/aws-sdk-go v1.44.281 // indirect
2930
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
3031
github.com/cloudflare/circl v1.3.3 // indirect
32+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
3133
github.com/davecgh/go-spew v1.1.1 // indirect
3234
github.com/emirpasic/gods v1.18.1 // indirect
3335
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
3436
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
35-
github.com/go-git/go-billy/v5 v5.4.1 // indirect
36-
github.com/go-git/go-git/v5 v5.8.1 // indirect
37+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
38+
github.com/go-git/go-git/v5 v5.9.0 // indirect
3739
github.com/go-logr/logr v1.2.4 // indirect
3840
github.com/go-logr/stdr v1.2.2 // indirect
3941
github.com/go-openapi/analysis v0.21.4 // indirect
@@ -56,7 +58,6 @@ require (
5658
github.com/google/uuid v1.3.0 // indirect
5759
github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect
5860
github.com/googleapis/gax-go/v2 v2.10.0 // indirect
59-
github.com/gruntwork-io/terratest v0.43.13 // indirect
6061
github.com/hashicorp/errwrap v1.1.0 // indirect
6162
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
6263
github.com/hashicorp/go-getter v1.7.1 // indirect
@@ -95,12 +96,12 @@ require (
9596
go.opentelemetry.io/otel/metric v1.16.0 // indirect
9697
go.opentelemetry.io/otel/trace v1.16.0 // indirect
9798
golang.org/x/crypto v0.13.0 // indirect
98-
golang.org/x/mod v0.10.0 // indirect
99-
golang.org/x/net v0.12.0 // indirect
99+
golang.org/x/mod v0.12.0 // indirect
100+
golang.org/x/net v0.15.0 // indirect
100101
golang.org/x/oauth2 v0.8.0 // indirect
101102
golang.org/x/sys v0.12.0 // indirect
102103
golang.org/x/text v0.13.0 // indirect
103-
golang.org/x/tools v0.9.3 // indirect
104+
golang.org/x/tools v0.13.0 // indirect
104105
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
105106
google.golang.org/api v0.127.0 // indirect
106107
google.golang.org/appengine v1.6.7 // indirect

tests/go.sum

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,16 @@ github.com/IBM-Cloud/power-go-client v1.3.1/go.mod h1:UBFlT5XKspkD1K0Wqd9evScL7d
196196
github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
197197
github.com/IBM/go-sdk-core/v5 v5.14.1 h1:WR1r0zz+gDW++xzZjF41r9ueY4JyjS2vgZjiYs8lO3c=
198198
github.com/IBM/go-sdk-core/v5 v5.14.1/go.mod h1:MUvIr/1mgGh198ZXL+ByKz9Qs1JoEh80v/96x8jPXNY=
199-
github.com/IBM/platform-services-go-sdk v0.48.1 h1:TT+v28xaaFDolswhFLc+2ut6KXukoNyJGhlhuJupV7g=
200-
github.com/IBM/platform-services-go-sdk v0.48.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU=
199+
github.com/IBM/platform-services-go-sdk v0.49.0 h1:Xd2pCCyjgrgTv8n+9oGoaYXBRCiKDcR4aT3J1bW1Ftw=
200+
github.com/IBM/platform-services-go-sdk v0.49.0/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU=
201201
github.com/IBM/vpc-go-sdk v1.0.2 h1:WhI1Cb8atA8glUdFg0SEUh9u8afjnKHxZAj9onQBi04=
202202
github.com/IBM/vpc-go-sdk v1.0.2/go.mod h1:42NO/XCXsyrYqpvtxoX5xwSEv/jBU1MKEoyaYkIUico=
203203
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
204204
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
205205
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
206206
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
207-
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs=
208-
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
207+
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
208+
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
209209
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
210210
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
211211
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
@@ -247,10 +247,12 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
247247
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
248248
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
249249
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
250+
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
251+
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
250252
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
251253
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
252254
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
253-
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0=
255+
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
254256
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
255257
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
256258
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -273,11 +275,11 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
273275
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
274276
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
275277
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
276-
github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
277-
github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
278+
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
279+
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
278280
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8=
279-
github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A=
280-
github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo=
281+
github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY=
282+
github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0=
281283
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
282284
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
283285
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -574,7 +576,7 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
574576
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
575577
github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
576578
github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc=
577-
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
579+
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
578580
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
579581
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
580582
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
@@ -591,7 +593,7 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
591593
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
592594
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
593595
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
594-
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
596+
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
595597
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
596598
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
597599
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
@@ -620,8 +622,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
620622
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
621623
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
622624
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
623-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.21.4 h1:QOhaXSYNSZW/8yrAk0EKulejDdCHaomv/LSvI9UhiaQ=
624-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.21.4/go.mod h1:FbnzpZl2Oxd1DGeHmqom1wH17pZS+e6nfW6L0huvMkI=
625+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.21.7 h1:U7a7qJW5wpEEk3DdBiF7xsuvtn0zWWWT65cbv3vZ/KQ=
626+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.21.7/go.mod h1:BiJPtkHaZOuS3xgI98WhK2uLjUjTMphE06+w/11+I30=
625627
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
626628
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
627629
github.com/tmccombs/hcl2json v0.5.0 h1:cT2sXStOzKL06c8ZTf9vh+0N8GKGzV7+9RUaY5/iUP8=
@@ -721,8 +723,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
721723
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
722724
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
723725
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
724-
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
725-
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
726+
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
727+
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
726728
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
727729
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
728730
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -781,8 +783,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
781783
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
782784
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
783785
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
784-
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
785-
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
786+
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
787+
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
786788
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
787789
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
788790
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -826,7 +828,7 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ
826828
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
827829
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
828830
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
829-
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
831+
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
830832
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
831833
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
832834
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -998,8 +1000,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
9981000
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
9991001
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
10001002
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
1001-
golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=
1002-
golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
1003+
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
1004+
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
10031005
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
10041006
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
10051007
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

tests/pr_test.go

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package test
22

33
import (
4+
"encoding/json"
5+
"fmt"
46
"log"
57
"os"
68
"testing"
79

10+
"github.com/gruntwork-io/terratest/modules/logger"
11+
"github.com/gruntwork-io/terratest/modules/terraform"
812
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
913
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
1014

@@ -77,7 +81,6 @@ func TestRunQuickStartPattern(t *testing.T) {
7781
}
7882

7983
func TestRunUpgradeQuickStartPattern(t *testing.T) {
80-
8184
t.Parallel()
8285

8386
options := setupOptionsQuickStartPattern(t, "vsi-qs-u", quickStartPatternTerraformDir)
@@ -216,3 +219,68 @@ func TestRunUpgradeVpcPattern(t *testing.T) {
216219
assert.NotNil(t, output, "Expected some output")
217220
}
218221
}
222+
223+
func TestRunOverride(t *testing.T) {
224+
t.Parallel()
225+
226+
options := setupOptionsQuickStartPattern(t, "slz-ovr", quickStartPatternTerraformDir)
227+
options.SkipTestTearDown = true
228+
output, err := options.RunTestConsistency()
229+
230+
if assert.Nil(t, err, "This should not have errored") &&
231+
assert.NotNil(t, output, "Expected some output") &&
232+
assert.NotNil(t, options.LastTestTerraformOutputs, "Expected some Terraform outputs") {
233+
// set override json string with previous value of config output
234+
options.TerraformOptions.Vars["override_json_string"] = options.LastTestTerraformOutputs["config"]
235+
236+
// TERRATEST uses its own internal logger.
237+
// The "show" command will produce a very large JSON to stdout which is printed by the logger.
238+
// We are temporarily turning the terratest logger OFF (discard) while running "show" to prevent large JSON stdout.
239+
options.TerraformOptions.Logger = logger.Discard
240+
planStruct, planErr := terraform.InitAndPlanAndShowWithStructE(options.Testing, options.TerraformOptions)
241+
options.TerraformOptions.Logger = logger.Default // turn log back on
242+
243+
if assert.Nil(t, planErr, "This should not have errored") &&
244+
assert.NotNil(t, planStruct, "Expected some output") {
245+
246+
// defines if at least one resource changed (destroy, update, etc)
247+
resourcesChanged := false
248+
for _, resource := range planStruct.ResourceChangesMap {
249+
// get JSON string of full changes for the logs
250+
changesBytes, changesErr := json.MarshalIndent(resource.Change, "", " ")
251+
// if it errors in the marshall step, just put a placeholder and move on, not important
252+
changesJson := "--UNAVAILABLE--"
253+
if changesErr == nil {
254+
changesJson = string(changesBytes)
255+
}
256+
257+
var resourceDetails string
258+
if resource.Change.Actions.Update() {
259+
resourceDetails = fmt.Sprintf("Name: %s Address: %s Actions: %s\nDIFF:\n%s\n\nChange Detail:\n%s", resource.Name, resource.Address, resource.Change.Actions, common.GetBeforeAfterDiff(changesJson), changesJson)
260+
} else {
261+
// Do not print changesJson because might expose secrets
262+
resourceDetails = fmt.Sprintf("Name: %s Address: %s Actions: %s\n", resource.Name, resource.Address, resource.Change.Actions)
263+
}
264+
265+
// build error message
266+
var errorMessage string
267+
errorMessage = fmt.Sprintf("Resource(s) identified to be destroyed %s", resourceDetails)
268+
269+
// check if current resource is changed
270+
noResourceChange := resource.Change.Actions.NoOp() || resource.Change.Actions.Read()
271+
assert.True(options.Testing, noResourceChange, errorMessage)
272+
273+
// if at least one resource is changed, then save that information
274+
if !resourcesChanged && !noResourceChange {
275+
resourcesChanged = true
276+
}
277+
}
278+
279+
// Run plan again to output the nice human-readable plan if there was a change
280+
if resourcesChanged {
281+
terraform.Plan(options.Testing, options.TerraformOptions)
282+
}
283+
}
284+
}
285+
options.TestTearDown()
286+
}

0 commit comments

Comments
 (0)