packer/packer_test/plugin_tests/gob_test_suite.go
Lucas Bajolet 56400f27cb packer_test: add gob/pb test suite
With the draft to support both gob and protobuf as serialisation formats
for Packer, along with the SDK changes that propel them, we add a series
of tests that make sure the logic that picks which protocol is solid and
functional.

These tests rely on building several versions of the tester plugin, with
and without protobuf support, to then install them in the tests as
needed to test the logic of Packer using packer build with them, and
templates that require multiple plugins.
2025-01-21 16:44:03 -05:00

38 lines
1.1 KiB
Go

package plugin_tests
import (
"testing"
"github.com/hashicorp/packer/packer_test/common"
"github.com/stretchr/testify/suite"
)
type PackerGobTestSuite struct {
*common.PackerTestSuite
}
func Test_PackerGobPBSuite(t *testing.T) {
baseSuite, cleanup := common.InitBaseSuite(t)
defer cleanup()
ts := &PackerGobTestSuite{
baseSuite,
}
var compilationJobs []chan common.CompilationResult
// Build two versions of each plugin, one with gob only, one with protobuf only
//
// We'll install them manually in tests, as they'll need to be installed as
// different plugin sources in order for discovery to trigger the
// gob-only/pb-supported behaviours we want to test.
compilationJobs = append(compilationJobs, ts.CompilePlugin("1.1.0+pb", common.UseDependency(common.SDKModule, "v0.6.0")))
compilationJobs = append(compilationJobs, ts.CompilePlugin("1.0.0+pb", common.UseDependency(common.SDKModule, "v0.6.0")))
compilationJobs = append(compilationJobs, ts.CompilePlugin("1.0.0+gob"))
compilationJobs = append(compilationJobs, ts.CompilePlugin("1.1.0+gob"))
common.Ready(t, compilationJobs)
suite.Run(t, ts)
}