Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Make plugin tests OS independent #459

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/gatewayd-plugin-cache@v0.2.10"
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
Loading