Skip to content

Commit

Permalink
Fix plugin install with no overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Dec 25, 2024
1 parent 8c47f3a commit c9e9dab
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cmd/plugin_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ func Test_pluginInstallCmdWithFile(t *testing.T) {
}

func Test_pluginInstallCmdAutomatedNoOverwrite(t *testing.T) {
pwd, err := os.Getwd()
require.NoError(t, err, "os.Getwd should not return an error")

pluginTestConfigFile := "./testdata/gatewayd_plugins.yaml"

// Test plugin install command with overwrite disabled
Expand All @@ -75,19 +72,25 @@ func Test_pluginInstallCmdAutomatedNoOverwrite(t *testing.T) {

// Verify expected output for no-overwrite case
assert.Contains(t, output, "Installing plugins from plugins configuration file")
assert.Contains(t, output, fmt.Sprintf("gatewayd-plugin-cache-%s-%s-", runtime.GOOS, runtime.GOARCH))
assert.Contains(
t,
output,
fmt.Sprintf("gatewayd-plugin-cache-%s-%s-", runtime.GOOS, runtime.GOARCH))
assert.Contains(t, output, "checksums.txt")
assert.Contains(t, output, "Download completed successfully")
assert.Contains(t, output, "Checksum verification passed")
assert.Contains(t, output, "Plugin binary extracted to plugins/gatewayd-plugin-cache")
assert.Contains(t, output, "Plugin installed successfully")

// Cleanup
// Clean up.
assert.FileExists(t, "plugins/gatewayd-plugin-cache")
assert.FileExists(t, pluginTestConfigFile+BackupFileExt)
assert.NoFileExists(t, "plugins/LICENSE")
assert.NoFileExists(t, "plugins/README.md")
assert.NoFileExists(t, "plugins/checksum.txt")
assert.NoFileExists(t, "plugins/gatewayd_plugin.yaml")

require.NoError(t, os.RemoveAll("plugins/"))
checksumFile := filepath.Join(pwd, "checksums.txt")
if _, err := os.Stat(checksumFile); err == nil {
require.NoError(t, os.Remove(checksumFile))
}
require.NoError(t, os.Remove(pluginTestConfigFile+BackupFileExt))
}

Expand Down

0 comments on commit c9e9dab

Please sign in to comment.