mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-21 23:41:41 -04:00
55 lines
2.1 KiB
Go
55 lines
2.1 KiB
Go
package packer_test
|
|
|
|
func (ts *PackerTestSuite) TestInstallPluginWithMetadata() {
|
|
tempPluginDir, cleanup := ts.MakePluginDir("1.0.0+metadata")
|
|
defer cleanup()
|
|
|
|
ts.Run("metadata plugin installed must not have metadata in its path", func() {
|
|
ts.PackerCommand().UsePluginDir(tempPluginDir).
|
|
SetArgs("plugins", "installed").
|
|
Assert(ts.T(), MustSucceed(), Grep("packer-plugin-tester_v1.0.0[^+]", grepStdout))
|
|
})
|
|
|
|
ts.Run("plugin with metadata should work with validate", func() {
|
|
ts.PackerCommand().UsePluginDir(tempPluginDir).
|
|
SetArgs("validate", "./templates/simple.pkr.hcl").
|
|
Assert(ts.T(), MustSucceed(), Grep("packer-plugin-tester_v1.0.0[^+][^\\n]+plugin:", grepStderr))
|
|
})
|
|
|
|
ts.Run("plugin with metadata should work with build", func() {
|
|
ts.PackerCommand().UsePluginDir(tempPluginDir).
|
|
SetArgs("build", "./templates/simple.pkr.hcl").
|
|
Assert(ts.T(), MustSucceed(), Grep("packer-plugin-tester_v1.0.0[^+][^\\n]+plugin:", grepStderr))
|
|
})
|
|
}
|
|
|
|
func (ts *PackerTestSuite) TestInstallPluginPrerelease() {
|
|
pluginPath := BuildSimplePlugin("1.0.1-alpha1", ts.T())
|
|
|
|
pluginDir, cleanup := ts.MakePluginDir()
|
|
defer cleanup()
|
|
|
|
ts.Run("try install plugin with alpha1 prerelease - should fail", func() {
|
|
ts.PackerCommand().UsePluginDir(pluginDir).
|
|
SetArgs("plugins", "install", "--path", pluginPath, "github.com/hashicorp/tester").
|
|
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))
|
|
})
|
|
}
|