mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 00:32:09 -04:00
test: add ExpectedInstalledName function
The ExpectedInstalledName function returns the expected full name of a plugin binary after it's installed. This is used for tests that need to copy the binary to some place before they can run commands and ensure the logic for managing plugins conforms to the docs/specs.
This commit is contained in:
parent
54a1d28525
commit
da41272df5
1 changed files with 18 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue