From 7124cf81fa02b9667e3bb20d918c06cfa3570e6e Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 15 May 2024 16:52:24 -0400 Subject: [PATCH] packer_test: test build/validate with ignore flag As we're introducing a --ignore-prerelease-plugins flag to both the validate and build subcommands, we need to make sure they work as we expect it to, so we add a test case for that. --- packer_test/loading_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packer_test/loading_test.go b/packer_test/loading_test.go index 2bbf39d70..5effa662b 100644 --- a/packer_test/loading_test.go +++ b/packer_test/loading_test.go @@ -195,3 +195,24 @@ func (ts *PackerTestSuite) TestLoadPluginWithMetadataInName() { MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) }) } + +func (ts *PackerTestSuite) TestLoadWithOnlyReleaseFlag() { + pluginPath, cleanup := ts.MakePluginDir("1.0.0", "1.0.1-dev") + defer cleanup() + + for _, cmd := range []string{"validate", "build"} { + ts.Run(fmt.Sprintf("run %s without --ignore-prerelease flag - pick 1.0.1-dev by default", cmd), func() { + ts.PackerCommand().UsePluginDir(pluginPath). + SetArgs(cmd, "./templates/simple.pkr.hcl"). + Assert(MustSucceed(), + Grep("packer-plugin-tester_v1.0.1-dev.*: plugin process exited", grepStderr)) + }) + + ts.Run(fmt.Sprintf("run %s with --ignore-prerelease flag - pick 1.0.0", cmd), func() { + ts.PackerCommand().UsePluginDir(pluginPath). + SetArgs(cmd, "--ignore-prerelease-plugins", "./templates/simple.pkr.hcl"). + Assert(MustSucceed(), + Grep("packer-plugin-tester_v1.0.0.*: plugin process exited", grepStderr)) + }) + } +}