From a49da983505923e70edccd782a75e330a41f01af Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 15 May 2024 16:23:02 -0400 Subject: [PATCH] packer_test: test non-canonical plugin loading If a plugin is installed with a non-canonical version in its name (e.g. 01.01.01), Packer rejects it with a message to that effect in stderr, so we add a test for this use-case. --- 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 97fa6d8a7..5309e0296 100644 --- a/packer_test/loading_test.go +++ b/packer_test/loading_test.go @@ -159,3 +159,21 @@ func (ts *PackerTestSuite) TestPluginPathEnvvarWithMultiplePaths() { SetTester(IntCompare(eq, 2))) }) } + +func (ts *PackerTestSuite) TestInstallNonCanonicalPluginVersion() { + pluginPath, cleanup := ts.MakePluginDir() + defer cleanup() + + ManualPluginInstall(ts.T(), + filepath.Join(pluginPath, "github.com", "hashicorp", "tester"), + BuildSimplePlugin("1.0.10", ts.T()), + "001.00.010") + + ts.Run("try listing plugins with non-canonical version installed - report none", func() { + ts.PackerCommand().UsePluginDir(pluginPath). + SetArgs("plugins", "installed"). + Assert(MustSucceed(), + Grep(`version .* in path is non canonical`, grepStderr), + MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout)) + }) +}