packer_test: add remote install with pre-rel test

Remotely installing plugins with a pre-release as part of the constraint
is unsupported by Packer, and should error if that happens.
This test makes sure that this gets treated as an error if that's the
case, even before attempting to connect to the source.
pull/12983/head
Lucas Bajolet 2 years ago
parent 37b33c5326
commit 59bff3bdbe

@ -77,10 +77,24 @@ func (ts *PackerTestSuite) TestRemoteInstallWithPluginsInstall() {
SetArgs("plugins", "install", "github.com/hashicorp/hashicups").
Assert(MustSucceed())
})
}
func (ts *PackerTestSuite) TestRemoteInstallOfPreReleasePlugin() {
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()
ts.Run("try to init with a pre-release constraint - should fail", func() {
ts.PackerCommand().UsePluginDir(pluginPath).
SetArgs("init", "templates/pre-release_constraint.pkr.hcl").
Assert(MustFail(),
Grep("Invalid version constraint", grepStdout),
Grep("Unsupported prerelease for constraint", grepStdout))
})
ts.Run("install dev version of a remote plugin with packer plugins install - must fail", func() {
ts.Run("try to plugins install with a pre-release version - should fail", func() {
ts.PackerCommand().UsePluginDir(pluginPath).
SetArgs("plugins", "install", "github.com/hashicorp/hashicups", "v1.0.2-dev").
Assert(MustFail(), Grep("Remote installation of pre-release plugin versions is unsupported.", grepStdout))
SetArgs("plugin", "install", "github.com/hashicorp/hashicups", "1.0.2-dev").
Assert(MustFail(),
Grep("Unsupported prerelease for constraint", grepStdout))
})
}

@ -0,0 +1,14 @@
packer {
required_plugins {
tester = {
source = "github.com/hashicorp/hashicups"
version = "= 1.0.2-dev"
}
}
}
source "tester-dynamic" "test" {}
build {
sources = ["tester-dynamic.test"]
}
Loading…
Cancel
Save