Files
Packer-Cn/test/loading_test.go
T
Lucas Bajolet 486c1d3dcb test: add base suite for core acceptance testing
Acceptance testing, i.e. running Packer core commands in a controlled
environment and ensuring the behaviour is consistent to what we
expect/document, is not something we have a robust and usable framework
for at the moment.

This commit is a proposal for a base testing framework of the sort, that
is meant to be shipped with packer core, and which will eventually host
most of the tests we currently do in command where we mock an
environment.
2024-06-10 09:59:32 -04:00

41 lines
858 B
Go

package test
import (
"os"
"testing"
)
func (ts *PackerTestSuite) TestLoadingOrder() {
t := ts.T()
pluginDir := ts.MakePluginDir(t, "1.0.9", "1.0.10")
defer func() {
err := os.RemoveAll(pluginDir)
if err != nil {
t.Logf("failed to remove temporary plugin directory %q: %s. This may need manual intervention.", pluginDir, err)
}
}()
tests := []struct {
name string
templatePath string
}{
{
"HCL2 - No required_plugins, 1.0.10 is the most recent and should load",
"./templates/simple.pkr.hcl",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ts.PackerCommand().
SetArgs("build", tt.templatePath).
AddEnv("PACKER_PLUGIN_PATH", pluginDir).
Assert(t, MustSucceed{}, Grep{
streams: BothStreams,
expect: "packer-plugin-tester_v1\\.0\\.10[^\n]+ plugin:",
})
})
}
}