mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 16:50:08 -04:00
added test cases for plugins getter
This commit is contained in:
parent
034e357bec
commit
d18efa1f96
1 changed files with 22 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ func TestRequirement_InstallLatestFromGithub(t *testing.T) {
|
|||
args{InstallOptions{
|
||||
[]Getter{
|
||||
&mockPluginGetter{
|
||||
Name: "github.com",
|
||||
Releases: []Release{
|
||||
{Version: "v1.2.3"},
|
||||
},
|
||||
|
|
@ -701,6 +702,27 @@ type mockPluginGetter struct {
|
|||
}
|
||||
|
||||
func (g *mockPluginGetter) Init(req *Requirement, entry *ChecksumFileEntry) error {
|
||||
filename := entry.Filename
|
||||
res := strings.TrimPrefix(filename, req.FilenamePrefix())
|
||||
// res now looks like v0.2.12_x5.0_freebsd_amd64.zip
|
||||
|
||||
entry.Ext = filepath.Ext(res)
|
||||
|
||||
res = strings.TrimSuffix(res, entry.Ext)
|
||||
// res now looks like v0.2.12_x5.0_freebsd_amd64
|
||||
|
||||
parts := strings.Split(res, "_")
|
||||
// ["v0.2.12", "x5.0", "freebsd", "amd64"]
|
||||
|
||||
if g.Name == "github.com" {
|
||||
|
||||
}
|
||||
if len(parts) < 4 {
|
||||
return fmt.Errorf("malformed filename expected %s{version}_x{protocol-version}_{os}_{arch}", req.FilenamePrefix())
|
||||
}
|
||||
|
||||
entry.BinVersion, entry.ProtVersion, entry.Os, entry.Arch = parts[0], parts[1], parts[2], parts[3]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue