backport of commit c856674a3e

backport/acc_test_logic/wrongly-witty-moccasin
Lucas Bajolet 2 years ago
parent cfe7efff2f
commit d4d2103c86

@ -1,6 +1,8 @@
package packer_test
import "strings"
import (
"strings"
)
func (ts *PackerTestSuite) TestInstallPluginWithMetadata() {
tempPluginDir, cleanup := ts.MakePluginDir("1.0.0+metadata")
@ -93,3 +95,27 @@ func (ts *PackerTestSuite) TestRemovePluginWithLocalPath() {
Assert(MustSucceed(), Grep("packer-plugin-tester_v1.0.10", grepStdout))
})
}
func (ts *PackerTestSuite) TestInitWithNonGithubSource() {
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()
ts.Run("try installing from a non-github source, should fail", func() {
ts.PackerCommand().UsePluginDir(pluginPath).
SetArgs("init", "./templates/non_gh.pkr.hcl").
Assert(MustFail(), Grep(`doesn't appear to be a valid "github.com" source address`, grepStdout))
})
ts.Run("manually install plugin to the expected source", func() {
ts.PackerCommand().UsePluginDir(pluginPath).
SetArgs("plugins", "install", "--path", BuildSimplePlugin("1.0.10", ts.T()), "hubgit.com/hashicorp/tester").
Assert(MustSucceed(), Grep("packer-plugin-tester_v1.0.10", grepStdout))
})
ts.Run("re-run packer init on same template, should succeed silently", func() {
ts.PackerCommand().UsePluginDir(pluginPath).
SetArgs("init", "./templates/non_gh.pkr.hcl").
Assert(MustSucceed(),
MkPipeCheck("no output in stdout").SetTester(ExpectEmptyInput()).SetStream(OnlyStdout))
})
}

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