test: add more tests for Packer core

pull/13032/head
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent c04ac1cb1c
commit 4a028ec735

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

@ -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").

Loading…
Cancel
Save