From 66e70a863dbcc803af7999493d5c4534b38044c7 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 15 May 2024 16:40:15 -0400 Subject: [PATCH] packer_test: add test for plugin with meta in name Plugins with metadata information in their file name (i.e. v1.0.0+metadata) should be ignored by Packer as they could introduce ambiguity since the metadata is free-form, so we add that test to make sure Packer behaves coherently. --- packer_test/loading_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packer_test/loading_test.go b/packer_test/loading_test.go index 5309e0296..2bbf39d70 100644 --- a/packer_test/loading_test.go +++ b/packer_test/loading_test.go @@ -177,3 +177,21 @@ func (ts *PackerTestSuite) TestInstallNonCanonicalPluginVersion() { MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) }) } + +func (ts *PackerTestSuite) TestLoadPluginWithMetadataInName() { + pluginPath, cleanup := ts.MakePluginDir() + defer cleanup() + + ManualPluginInstall(ts.T(), + filepath.Join(pluginPath, "github.com", "hashicorp", "tester"), + BuildSimplePlugin("1.0.10+metadata", ts.T()), + "1.0.10+metadata") + + ts.Run("try listing plugins with metadata in name - report none", func() { + ts.PackerCommand().UsePluginDir(pluginPath). + SetArgs("plugins", "installed"). + Assert(MustSucceed(), + Grep("found version .* with metadata in the name", grepStderr), + MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) + }) +}