Skip to content

Commit

Permalink
test: Make plugin test OS independant (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamsajj authored Feb 29, 2024
1 parent 00a7b82 commit debb05c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func TestGetProxies(t *testing.T) {
Address: config.DefaultAddress,
}
client := network.NewClient(context.TODO(), clientConfig, zerolog.Logger{}, nil)
require.NotNil(t, client)
newPool := pool.NewPool(context.TODO(), 1)
assert.Nil(t, newPool.Put(client.ID, client))

Expand Down
11 changes: 10 additions & 1 deletion cmd/cmd_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package cmd

import (
"bytes"
"fmt"
"os"
"path/filepath"
"runtime"

"github.com/spf13/cobra"
)
Expand All @@ -24,7 +26,14 @@ func executeCommandC(root *cobra.Command, args ...string) (string, error) {
// mustPullPlugin pulls the gatewayd-plugin-cache plugin and returns the path to the archive.
func mustPullPlugin() (string, error) {
pluginURL := "github.com/gatewayd-io/[email protected]"
fileName := "./gatewayd-plugin-cache-linux-amd64-v0.2.10.tar.gz"

fileName := fmt.Sprintf(
"./gatewayd-plugin-cache-%s-%s-%s%s",
runtime.GOOS,
runtime.GOARCH,
"v0.2.10",
getFileExtension(),
)

if _, err := os.Stat(fileName); os.IsNotExist(err) {
_, err := executeCommandC(rootCmd, "plugin", "install", "--pull-only", pluginURL)
Expand Down
3 changes: 2 additions & 1 deletion cmd/plugin_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"os"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -64,7 +65,7 @@ func Test_pluginInstallCmdAutomatedNoOverwrite(t *testing.T) {
rootCmd, "plugin", "install",
"-p", pluginTestConfigFile, "--update", "--backup", "--overwrite-config=false")
require.NoError(t, err, "plugin install should not return an error")
assert.Contains(t, output, "/gatewayd-plugin-cache-linux-amd64-")
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")
Expand Down

0 comments on commit debb05c

Please sign in to comment.