Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Dec 22, 2024
1 parent 9cd32a9 commit b60265f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 50 deletions.
12 changes: 2 additions & 10 deletions cmd/plugin_scaffold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/codingsince1985/checksum"
"github.com/gatewayd-io/gatewayd/config"
"github.com/gatewayd-io/gatewayd/plugin"
"github.com/gatewayd-io/gatewayd/testhelpers"
"github.com/spf13/cast"
Expand Down Expand Up @@ -87,7 +86,7 @@ func Test_pluginScaffoldCmd(t *testing.T) {

pluginTestConfigFile := filepath.Join(pluginDir, "gatewayd_plugins.yaml")

stopChan = make(chan struct{})
App.stopChan = make(chan struct{})

var waitGroup sync.WaitGroup

Expand All @@ -114,14 +113,7 @@ func Test_pluginScaffoldCmd(t *testing.T) {
StopGracefully(
context.Background(),
nil,
nil,
metricsServer,
nil,
loggers[config.Default],
servers,
stopChan,
nil,
nil,
App,
)

waitGroup.Done()
Expand Down
50 changes: 10 additions & 40 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"
"time"

"github.com/gatewayd-io/gatewayd/config"
"github.com/gatewayd-io/gatewayd/testhelpers"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -41,7 +40,7 @@ func Test_runCmd(t *testing.T) {
// Check that the config file was created.
assert.FileExists(t, globalTestConfigFile, "configInitCmd should create a config file")

stopChan = make(chan struct{})
App.stopChan = make(chan struct{})

var waitGroup sync.WaitGroup

Expand All @@ -67,14 +66,7 @@ func Test_runCmd(t *testing.T) {
StopGracefully(
context.Background(),
nil,
nil,
metricsServer,
nil,
loggers[config.Default],
servers,
stopChan,
nil,
nil,
App,
)

waitGroup.Done()
Expand Down Expand Up @@ -104,7 +96,7 @@ func Test_runCmdWithTLS(t *testing.T) {
require.NoError(t, err, "plugin init command should not have returned an error")
assert.FileExists(t, pluginTestConfigFile, "plugin init command should have created a config file")

stopChan = make(chan struct{})
App.stopChan = make(chan struct{})

var waitGroup sync.WaitGroup
// TODO: Test client certificate authentication.
Expand Down Expand Up @@ -133,14 +125,7 @@ func Test_runCmdWithTLS(t *testing.T) {
StopGracefully(
context.Background(),
nil,
nil,
metricsServer,
nil,
loggers[config.Default],
servers,
stopChan,
nil,
nil,
App,
)

waitGroup.Done()
Expand Down Expand Up @@ -172,7 +157,7 @@ func Test_runCmdWithMultiTenancy(t *testing.T) {
require.NoError(t, err, "plugin init command should not have returned an error")
assert.FileExists(t, pluginTestConfigFile, "plugin init command should have created a config file")

stopChan = make(chan struct{})
App.stopChan = make(chan struct{})

var waitGroup sync.WaitGroup

Expand Down Expand Up @@ -203,14 +188,7 @@ func Test_runCmdWithMultiTenancy(t *testing.T) {
StopGracefully(
context.Background(),
nil,
nil,
metricsServer,
nil,
loggers[config.Default],
servers,
stopChan,
nil,
nil,
App,
)

waitGroup.Done()
Expand All @@ -233,9 +211,8 @@ func Test_runCmdWithCachePlugin(t *testing.T) {

globalTestConfigFile := "./test_global_runCmdWithCachePlugin.yaml"
pluginTestConfigFile := "./test_plugins_runCmdWithCachePlugin.yaml"
// TODO: Remove this once these global variables are removed from cmd/run.go.
// https://github.com/gatewayd-io/gatewayd/issues/324
stopChan = make(chan struct{})

App.stopChan = make(chan struct{})

// Create a test plugins config file.
_, err := executeCommandC(rootCmd, "plugin", "init", "--force", "-p", pluginTestConfigFile)
Expand Down Expand Up @@ -265,7 +242,7 @@ func Test_runCmdWithCachePlugin(t *testing.T) {
require.NoError(t, err, "plugin list should not return an error")
assert.Contains(t, output, "Name: gatewayd-plugin-cache")

stopChan = make(chan struct{})
App.stopChan = make(chan struct{})

var waitGroup sync.WaitGroup

Expand All @@ -291,14 +268,7 @@ func Test_runCmdWithCachePlugin(t *testing.T) {
StopGracefully(
context.Background(),
nil,
nil,
metricsServer,
nil,
loggers[config.Default],
servers,
stopChan,
nil,
nil,
App,
)

waitGroup.Done()
Expand Down

0 comments on commit b60265f

Please sign in to comment.