mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-11 09:40:17 -04:00
test: add more tests for Packer core
This commit is contained in:
parent
c04ac1cb1c
commit
4a028ec735
2 changed files with 40 additions and 1 deletions
|
|
@ -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…
Reference in a new issue