packer_test: add SkipNoAcc function

The SkipNoAcc function on PackerTestSuite allows to mark a test run as
not to be run every time we run `make test`, but only when PACKER_ACC=1
is set in the environment.

This allows us to skip executing tests that are either long-running, or
that depend on external dependencies (typically Github), which have a
higher potential to fail on a normal run of Packer tests.
nywilken.document-tmpdir
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent d65074c05c
commit dbaaab512a

@ -1,6 +1,8 @@
package packer_test
func (ts *PackerTestSuite) TestPackerInitForce() {
ts.SkipNoAcc()
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()
@ -18,6 +20,8 @@ func (ts *PackerTestSuite) TestPackerInitForce() {
}
func (ts *PackerTestSuite) TestPackerInitUpgrade() {
ts.SkipNoAcc()
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()
@ -62,6 +66,8 @@ func (ts *PackerTestSuite) TestPackerInitWithNonGithubSource() {
}
func (ts *PackerTestSuite) TestPackerInitWithMixedVersions() {
ts.SkipNoAcc()
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()

@ -69,6 +69,8 @@ func (ts *PackerTestSuite) TestInstallPluginPrerelease() {
}
func (ts *PackerTestSuite) TestRemoteInstallWithPluginsInstall() {
ts.SkipNoAcc()
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()
@ -80,6 +82,8 @@ func (ts *PackerTestSuite) TestRemoteInstallWithPluginsInstall() {
}
func (ts *PackerTestSuite) TestRemoteInstallOfPreReleasePlugin() {
ts.SkipNoAcc()
pluginPath, cleanup := ts.MakePluginDir()
defer cleanup()

@ -42,6 +42,20 @@ func (ts *PackerTestSuite) buildPluginBinaries(t *testing.T) {
wg.Wait()
}
// SkipNoAcc is a pre-condition that skips the test if the PACKER_ACC environment
// variable is unset, or set to "0".
//
// This allows us to build tests with a potential for long runs (or errors like
// rate-limiting), so we can still test them, but only in a longer timeouted
// context.
func (ts *PackerTestSuite) SkipNoAcc() {
acc := os.Getenv("PACKER_ACC")
if acc == "" || acc == "0" {
ts.T().Logf("Skipping test as `PACKER_ACC` is unset.")
ts.T().Skip()
}
}
func Test_PackerCoreSuite(t *testing.T) {
ts := &PackerTestSuite{}

Loading…
Cancel
Save