From 830ac98e3979b155918698324c02c86103e8f2ee Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Fri, 10 May 2024 11:23:05 -0400 Subject: [PATCH] packer_test: add test for multiple plugin paths When the PACKER_PLUGIN_PATH envvar is defined in the environment, Packer uses it as the source of truth for the directories in which to look for plugins to load. Previously, we used to support multiple directories separated by the OS-specific path separator (i.e. : on UNIX, ; on Windows). Since this changed, and Packer returns an error to the user, we make sure that this is well-documented and tested through this extra test. --- packer_test/loading_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packer_test/loading_test.go b/packer_test/loading_test.go index 057d9ea85..1d277580c 100644 --- a/packer_test/loading_test.go +++ b/packer_test/loading_test.go @@ -3,6 +3,7 @@ package packer_test import ( "crypto/sha256" "fmt" + "os" "path/filepath" "runtime" "strings" @@ -140,3 +141,26 @@ func (ts *PackerTestSuite) TestLoadWithSHAMismatches() { Grep(`Checksums \(\*sha256\.digest\) did not match.`, grepStderr)) }) } + +func (ts *PackerTestSuite) TestPluginPathEnvvarWithMultiplePaths() { + pluginDirOne, cleanup := ts.MakePluginDir("1.0.10") + defer cleanup() + + pluginDirTwo, cleanup := ts.MakePluginDir("1.0.9") + defer cleanup() + + pluginDirVal := fmt.Sprintf("%s%c%s", pluginDirOne, os.PathListSeparator, pluginDirTwo) + ts.Run("load plugin with two dirs - not supported anymore, should error", func() { + ts.PackerCommand().UsePluginDir(pluginDirVal). + SetArgs("plugins", "installed"). + Assert(ts.T(), MustFail(), + Grep("Multiple paths are no longer supported for PACKER_PLUGIN_PATH"), + PipeChecker{ + check: IntCompare(eq, 2), + pipers: []Pipe{ + PipeGrep(`\* PACKER_PLUGIN_PATH=`), + LineCount(), + }, + }) + }) +}