diff --git a/test/e2e/quickstart_test.go b/test/e2e/quickstart_test.go index 54ad1237..a6459f7c 100644 --- a/test/e2e/quickstart_test.go +++ b/test/e2e/quickstart_test.go @@ -9,10 +9,13 @@ import ( "testing" helper "github.com/Azure/terraform-module-test-helper" + "github.com/agiledragon/gomonkey/v2" "github.com/gruntwork-io/terratest/modules/files" "github.com/gruntwork-io/terratest/modules/packer" + "github.com/gruntwork-io/terratest/modules/shell" "github.com/gruntwork-io/terratest/modules/terraform" test_structure "github.com/gruntwork-io/terratest/modules/test-structure" + terratest "github.com/gruntwork-io/terratest/modules/testing" "github.com/stretchr/testify/require" ) @@ -128,6 +131,21 @@ func test201VmssPackerJumpbox(t *testing.T) { if tenantId := os.Getenv("ARM_TENANT_ID"); !useMsi && tenantId != "" { packerVars["tenant_id"] = tenantId } + patches := gomonkey.ApplyFunc(shell.RunCommandAndGetOutputE, func(t terratest.TestingT, command shell.Command) (string, error) { + output, err := shell.RunCommandAndGetStdOutE(t, command) + if err != nil { + return output, err + } + + if len(command.Args) == 1 && command.Args[0] == "-version" { + output = strings.TrimPrefix(output, "Packer ") + output = strings.TrimPrefix(output, "v") + output = strings.Split(output, "\n")[0] + } + return output, nil + }) + defer patches.Reset() + _, err := packer.BuildArtifactE(t, &packer.Options{ Template: pkrCfg, Vars: packerVars, diff --git a/test/go.mod b/test/go.mod index f0d81550..87fec874 100644 --- a/test/go.mod +++ b/test/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( github.com/Azure/terraform-module-test-helper v0.16.0 + github.com/agiledragon/gomonkey/v2 v2.11.0 github.com/gruntwork-io/terratest v0.43.9 github.com/stretchr/testify v1.8.4 )