Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test cases
Browse files Browse the repository at this point in the history
On Windows the exec.LookPath just checks that a file ends with the appropriate extension
so this fails the test because the mock file is executed when it shouldn't be. In the realworld,
this is an error but for files that don't have a proper extension Packer should ignore them.

For Unix there is no extension so it is valid to check if the file is executable.
nywilken committed May 26, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
suzuki-shunsuke Shunsuke Suzuki
1 parent b746f50 commit 759ec69
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packer/plugin_discover_test.go
Original file line number Diff line number Diff line change
@@ -157,9 +157,23 @@ func TestDiscoverDatasource(t *testing.T) {
func TestDiscover_NonExecutableMultiComponentPlugins(t *testing.T) {
pluginNames := []string{"packer-plugin-partyparrot", "packer-plugin-happycloud", "packer-plugin-long-name-component"}
// Create a temporary directory to store plugins in
dir, _, cleanUpFunc, err := generateFakePlugins("custom_plugin_dir", pluginNames)
dir, err := os.MkdirTemp("", "custom_plugin_dir")
if err != nil {
t.Fatalf("Error creating fake custom plugins: %s", err)
t.Fatalf("failed to create temporary test directory: %v", err)
}

cleanUpFunc := func() {
os.RemoveAll(dir)
}

plugins := make([]string, len(pluginNames))
for i, plugin := range pluginNames {
plug := filepath.Join(dir, plugin)
plugins[i] = plug
_, err := os.Create(plug)
if err != nil {
t.Fatalf("failed to create fake plugins for testing: %v", err)
}
}

defer cleanUpFunc()

0 comments on commit 759ec69

Please sign in to comment.