packer_test: fix shasum file name for tests

When manually installing a plugin to the plugin directory, we compute a
SHA256SUM file from the plugin binary, and install it alongside it so we
can test the loading process for Packer.

In the introduction of the function, we added a check that if we were
running on Windows, we'd remove the extension of the sumfile's name
before writing it.

This is actually not necessary (and breaks the loading logic) as Packer
looks for the name of the plugin with extension, followed by
_SHA256SUM in order to compare the effective digest of the file to the
one written to this file.

Since this prevents the tests that use this function from succeeding in
a Windows environment, we remove this extra step.
pull/12983/head
Lucas Bajolet 2 years ago
parent 60d46ec146
commit 40a23400e9

@ -5,8 +5,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
)
func (ts *PackerTestSuite) TestLoadingOrder() {
@ -119,14 +117,9 @@ func (ts *PackerTestSuite) TestLoadWithSHAMismatches() {
defer cleanup()
pluginDestName := ExpectedInstalledName("1.0.10")
noExtDest := pluginDestName
if runtime.GOOS == "windows" {
noExtDest = strings.Replace(pluginDestName, ".exe", "", 1)
}
CopyFile(ts.T(), filepath.Join(pluginDir, "github.com", "hashicorp", "tester", pluginDestName), plugin)
WriteFile(ts.T(),
filepath.Join(pluginDir, "github.com", "hashicorp", "tester", fmt.Sprintf("%s_SHA256SUM", noExtDest)),
filepath.Join(pluginDir, "github.com", "hashicorp", "tester", fmt.Sprintf("%s_SHA256SUM", pluginDestName)),
fmt.Sprintf("%x", sha256.New().Sum([]byte("Not the plugin's contents for sure."))))
ts.PackerCommand().UsePluginDir(pluginDir).

@ -328,10 +328,6 @@ func ManualPluginInstall(t *testing.T, dest, srcPlugin, versionStr string) {
CopyFile(t, destPath, srcPlugin)
shaPath := destPath
if runtime.GOOS == "windows" {
shaPath = strings.Replace(destPath, ".exe", "", 1)
}
shaPath = fmt.Sprintf("%s_SHA256SUM", shaPath)
shaPath := fmt.Sprintf("%s_SHA256SUM", destPath)
WriteFile(t, shaPath, SHA256Sum(t, destPath))
}

Loading…
Cancel
Save