Skip to content

Commit

Permalink
Add test for install pluggin from file with args
Browse files Browse the repository at this point in the history
  • Loading branch information
--global committed Jan 27, 2024
1 parent 42d6a9a commit f214f14
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cmd/plugin_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,46 @@ func Test_pluginInstallCmdAutomatedNoOverwrite(t *testing.T) {
require.NoError(t, os.RemoveAll("plugins/"))
require.NoError(t, os.Remove(fmt.Sprintf("%s.bak", pluginTestConfigFile)))
}

func Test_pluginInstallCmdWithArgs(t *testing.T) {
pluginTestConfigFile := "./testdata/gatewayd_plugins.yaml"
pluginTestPath := "./testdata/gatewayd-plugin-cache-linux-amd64-v0.2.8.tar.gz"
pluginTestName := "plugin-cache"
// Test plugin install command.
output, err := executeCommandC(
rootCmd, "plugin", "install",
pluginTestPath, "--name", pluginTestName)
require.NoError(t, err, "plugin install should not return an error")
assert.Contains(t, output, "Installing plugin from CLI argumen")
assert.Contains(t, output, "Plugin installed successfully")

// See if the plugin was actually installed.
output, err = executeCommandC(rootCmd, "plugin", "list", "-p", pluginTestConfigFile)
require.NoError(t, err, "plugin list should not return an error")
assert.Contains(t, output, "Name: gatewayd-plugin-cache")

// Clean up.
assert.FileExists(t, "plugins/gatewayd-plugin-cache")
assert.FileExists(t, fmt.Sprintf("%s.bak", pluginTestConfigFile))
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/"))
require.NoError(t, os.Remove(fmt.Sprintf("%s.bak", pluginTestConfigFile)))
}


Check failure on line 118 in cmd/plugin_install_test.go

View workflow job for this annotation

GitHub Actions / Test GatewayD

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
func Test_pluginInstallCmdWithArgsWithOutName(t *testing.T) {
pluginTestPath := "./testdata/gatewayd-plugin-cache-linux-amd64-v0.2.8.tar.gz"
// Test plugin install command.
output, err := executeCommandC(
rootCmd, "plugin", "install",
pluginTestPath)
require.NoError(t, err, "plugin install should be return an error")
assert.Contains(t, output, "Installing plugin from CLI argumen")
assert.Contains(t, output, "Plugin name not specified")

Check failure on line 128 in cmd/plugin_install_test.go

View workflow job for this annotation

GitHub Actions / Test GatewayD

File is not `gofumpt`-ed (gofumpt)
}

Check failure on line 130 in cmd/plugin_install_test.go

View workflow job for this annotation

GitHub Actions / Test GatewayD

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
Binary file not shown.

0 comments on commit f214f14

Please sign in to comment.