github getter test cases

anshul/plugin_binary_from_official_site
anshul sharma 10 months ago
parent f8d6076305
commit 37273a55fd

@ -321,10 +321,10 @@ func (g *Getter) Init(req *plugingetter.Requirement, entry *plugingetter.Checksu
func (g *Getter) Validate(opt plugingetter.GetOptions, expectedVersion string, installOpts plugingetter.BinaryInstallationOptions, entry *plugingetter.ChecksumFileEntry) error {
expectedBinVersion := "v" + expectedVersion
if entry.BinVersion != expectedBinVersion {
return fmt.Errorf("wrong version: '%s' does not match expected %s ", entry.BinVersion, expectedBinVersion)
return fmt.Errorf("wrong version: %s does not match expected %s", entry.BinVersion, expectedBinVersion)
}
if entry.Os != installOpts.OS || entry.Arch != installOpts.ARCH {
return fmt.Errorf("wrong system, expected %s_%s ", installOpts.OS, installOpts.ARCH)
return fmt.Errorf("wrong system, expected %s_%s", installOpts.OS, installOpts.ARCH)
}
return installOpts.CheckProtocolVersion(entry.ProtVersion)

@ -525,13 +525,13 @@ func (binOpts *BinaryInstallationOptions) CheckProtocolVersion(remoteProt string
}
if localVersion.Major != remoteVersion.Major {
return fmt.Errorf("Unsupported remote protocol MAJOR version %d. The current MAJOR protocol version is %d."+
" This version of Packer can only communicate with plugins using that version.", remoteVersion.Major, localVersion.Major)
return fmt.Errorf("unsupported remote protocol MAJOR version %d. The current MAJOR protocol version is %d."+
" This version of Packer can only communicate with plugins using that version", remoteVersion.Major, localVersion.Major)
}
if remoteVersion.Minor > localVersion.Minor {
return fmt.Errorf("Unsupported remote protocol MINOR version %d. The supported MINOR protocol versions are version %d and below. "+
"Please upgrade Packer or use an older version of the plugin if possible.", remoteVersion.Minor, localVersion.Minor)
return fmt.Errorf("unsupported remote protocol MINOR version %d. The supported MINOR protocol versions are version %d and below. "+
"Please upgrade Packer or use an older version of the plugin if possible", remoteVersion.Minor, localVersion.Minor)
}
return nil

@ -756,42 +756,6 @@ func (g *mockPluginGetter) Get(what string, options GetOptions) (io.ReadCloser,
return io.NopCloser(read), nil
}
/*func (g *mockPluginGetter) GetOfficialRelease(what string, options GetOptions) (io.ReadCloser, error) {
var toEncode interface{}
switch what {
case "releases":
toEncode = g.Releases
case "sha256":
enc, ok := g.ChecksumFileEntries[options.version.String()]
if !ok {
return nil, fmt.Errorf("No checksum available for version %q", options.version.String())
}
toEncode = enc
case "zip":
// Note: we'll act as if the plugin sources would always be github sources for now.
// This test will need to be updated if/when we move on to support other sources.
parts := options.PluginRequirement.Identifier.Parts()
acc := fmt.Sprintf("%s/%s/packer-plugin-%s/%s", parts[0], parts[1], parts[2], options.ExpectedZipFilename())
zip, found := g.Zips[acc]
if found == false {
panic(fmt.Sprintf("could not find zipfile %s. %v", acc, g.Zips))
}
return zip, nil
default:
panic("Don't know how to get " + what)
}
read, write := io.Pipe()
go func() {
if err := json.NewEncoder(write).Encode(toEncode); err != nil {
panic(err)
}
}()
return io.NopCloser(read), nil
}*/
func zipFile(content map[string]string) io.ReadCloser {
buff := bytes.NewBuffer(nil)
zipWriter := zip.NewWriter(buff)

Loading…
Cancel
Save