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.
pull/13032/head
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent 3d437ede99
commit fe564c579b

@ -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()

Loading…
Cancel
Save