diff --git a/test/install_test.go b/test/install_test.go index 02c11882a..d8f9be02d 100644 --- a/test/install_test.go +++ b/test/install_test.go @@ -35,3 +35,20 @@ func (ts *PackerTestSuite) TestInstallPluginPrerelease() { Assert(ts.T(), MustFail(), Grep("Packer can only install plugin releases with this command", grepStdout)) }) } + +func (ts *PackerTestSuite) TestRemoteInstallWithPluginsInstall() { + pluginPath, cleanup := ts.MakePluginDir() + defer cleanup() + + ts.Run("install latest version of a remote plugin with packer plugins install", func() { + ts.PackerCommand().UsePluginDir(pluginPath). + SetArgs("plugins", "install", "github.com/hashicorp/hashicups"). + Assert(ts.T(), MustSucceed()) + }) + + ts.Run("install dev version of a remote plugin with packer plugins install - must fail", func() { + ts.PackerCommand().UsePluginDir(pluginPath). + SetArgs("plugins", "install", "github.com/hashicorp/hashicups", "v1.0.2-dev"). + Assert(ts.T(), MustFail(), Grep("Remote installation of pre-release plugin versions is unsupported.", grepStdout)) + }) +} diff --git a/test/loading_test.go b/test/loading_test.go index 20ff7071d..9889410be 100644 --- a/test/loading_test.go +++ b/test/loading_test.go @@ -50,13 +50,35 @@ func (ts *PackerTestSuite) TestLoadingOrder() { } func (ts *PackerTestSuite) TestLoadWithLegacyPluginName() { - pluginDir, cleanup := ts.MakePluginDir("1.0.0") + pluginDir, cleanup := ts.MakePluginDir() defer cleanup() plugin := BuildSimplePlugin("1.0.10", ts.T()) CopyFile(ts.T(), filepath.Join(pluginDir, "packer-plugin-tester"), plugin) + ts.Run("only legacy plugins installed: expect build to fail", func() { + ts.Run("with required_plugins - expect prompt for packer init", func() { + ts.PackerCommand().UsePluginDir(pluginDir). + SetArgs("build", "templates/simple.pkr.hcl"). + Assert(ts.T(), MustFail(), + Grep("Did you run packer init for this project", grepStdout), + Grep("following plugins are required", grepStdout)) + }) + + ts.Run("JSON template, without required_plugins: should say the component is unknown", func() { + ts.PackerCommand().UsePluginDir(pluginDir). + SetArgs("build", "templates/simple.json"). + Assert(ts.T(), MustFail(), + Grep("The builder tester-dynamic is unknown by Packer", grepStdout)) + }) + }) + + pluginDir, cleanup = ts.MakePluginDir("1.0.0") + defer cleanup() + + CopyFile(ts.T(), filepath.Join(pluginDir, "packer-plugin-tester"), plugin) + ts.Run("multiple plugins installed: one with no version in path, one with qualified name. Should pick-up the qualified one only.", func() { ts.PackerCommand().UsePluginDir(pluginDir). SetArgs("build", "templates/simple.pkr.hcl").