From 0224d6e0dec58e19486ee32c7a34edc5bd5cd37f Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 9 Nov 2022 17:15:53 -0500 Subject: [PATCH] plugin_test: error on missing checksum file The mockPluginGetter would always succeed in returning a file from the list of suggested releases, which does not let us test what happens when a release is not yet complete, and a checksum file fails to be fetched from the source. This commit changes this behaviour so that we get an error when a checksum does not exist, mirrorring what happens in real conditions. --- packer/plugin-getter/plugins_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packer/plugin-getter/plugins_test.go b/packer/plugin-getter/plugins_test.go index 1e3fbe0b7..1da3bfb5b 100644 --- a/packer/plugin-getter/plugins_test.go +++ b/packer/plugin-getter/plugins_test.go @@ -676,7 +676,11 @@ func (g *mockPluginGetter) Get(what string, options GetOptions) (io.ReadCloser, case "releases": toEncode = g.Releases case "sha256": - toEncode = g.ChecksumFileEntries[options.version.String()] + 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": acc := options.PluginRequirement.Identifier.Hostname + "/" + options.PluginRequirement.Identifier.RealRelativePath() + "/" +