test: add installation tests to acceptance tests

This commit adds a few scenarios of plugin installations to the test
suite, in order to document and ensure we behave appropriately when
installing pre-releases/metadata.
pull/13032/head
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent fe564c579b
commit ad4631fb67

@ -0,0 +1,49 @@
package 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{
streams: OnlyStdout,
expect: "packer-plugin-tester_v1.0.0[^+]",
})
})
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{
streams: OnlyStderr,
expect: "packer-plugin-tester_v1.0.0[^+][^\\n]+plugin:",
})
})
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{
streams: OnlyStderr,
expect: "packer-plugin-tester_v1.0.0[^+][^\\n]+plugin:",
})
})
}
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{
streams: OnlyStdout,
expect: "Packer can only install plugin releases with this command",
})
})
}

@ -34,8 +34,8 @@ func (ts *PackerTestSuite) buildPluginBinaries(t *testing.T) {
wg := &sync.WaitGroup{}
buildPluginVersion(wg, "1.0.0", t)
buildPluginVersion(wg, "1.0.1-dev", t)
buildPluginVersion(wg, "1.0.1", t)
buildPluginVersion(wg, "1.0.0+metadata", t)
buildPluginVersion(wg, "1.0.1-alpha1", t)
buildPluginVersion(wg, "1.0.9", t)
buildPluginVersion(wg, "1.0.10", t)

Loading…
Cancel
Save