From 2d32f073f46c0064b60d992c432730f6f1e5b660 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Fri, 3 May 2024 20:36:23 +0000 Subject: [PATCH] backport of commit c1a0002a10718fbc3f573d65f1013311044a0685 --- test/plugin_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/plugin_test.go b/test/plugin_test.go index 84492035a..e97c0c21f 100644 --- a/test/plugin_test.go +++ b/test/plugin_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/hashicorp/go-version" + "github.com/hashicorp/packer-plugin-sdk/plugin" ) var compiledPlugins = struct { @@ -83,6 +84,23 @@ func BinaryName(version *version.Version) string { return retStr } +// ExpectedInstalledName is the expected full name of the plugin once installed. +func ExpectedInstalledName(versionStr string) string { + v := version.Must(version.NewSemver(versionStr)) + + ext := "" + if runtime.GOOS == "windows" { + ext = ".exe" + } + + return fmt.Sprintf("packer-plugin-tester_v%s%s_x%s.%s_%s_%s%s", + v.Core().String(), + v.Prerelease(), + plugin.APIVersionMajor, + plugin.APIVersionMinor, + runtime.GOOS, runtime.GOARCH, ext) +} + // BuildSimplePlugin creates a plugin that essentially does nothing. // // The plugin's code is contained in a subdirectory of this, and lets us