From fe564c579bb9709847f47547df36be8159f25408 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Fri, 3 May 2024 15:39:14 -0400 Subject: [PATCH] test: error on plugin loading if not compiled When building the temporary plugin directory for a test, we didn't check that the LoadPluginVersion call succeeded and returned a path, which may cause errors down the line when attempting to install the plugin. To avoid this problem, we do the check at that time, and immediately fail if a plugin isn't found. --- test/plugin_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/plugin_test.go b/test/plugin_test.go index 28abbf59b..84492035a 100644 --- a/test/plugin_test.go +++ b/test/plugin_test.go @@ -170,7 +170,10 @@ func (ts *PackerTestSuite) MakePluginDir(pluginVersions ...string) (pluginTempDi } for _, pluginVersion := range pluginVersions { - path, _ := LoadPluginVersion(pluginVersion) + path, ok := LoadPluginVersion(pluginVersion) + if !ok { + err = fmt.Errorf("failed to get path to version %q, was it compiled?", pluginVersion) + } cmd := ts.PackerCommand().SetArgs("plugins", "install", "--path", path, "github.com/hashicorp/tester").AddEnv("PACKER_PLUGIN_PATH", pluginTempDir) cmd.Assert(t, MustSucceed{}) out, stderr, cmdErr := cmd.Run()