From 6debf666b354f6d7f52b9f60fcab891227fd75b9 Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Mon, 23 Dec 2024 14:55:43 +0100 Subject: [PATCH] Fix tests --- api/http_server_test.go | 1 + cmd/plugin_install_test.go | 2 ++ cmd/plugin_list_test.go | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/api/http_server_test.go b/api/http_server_test.go index 77a6e36c..3ee0fafc 100644 --- a/api/http_server_test.go +++ b/api/http_server_test.go @@ -16,6 +16,7 @@ import ( // Test_HTTP_Server tests the HTTP to gRPC gateway. func Test_HTTP_Server(t *testing.T) { api := getAPIConfig() + api.Servers[config.Default].Address = ":0" healthchecker := &HealthChecker{Servers: api.Servers} grpcServer := NewGRPCServer( context.Background(), GRPCServer{API: api, HealthChecker: healthchecker}) diff --git a/cmd/plugin_install_test.go b/cmd/plugin_install_test.go index 38c82a0a..baae5d24 100644 --- a/cmd/plugin_install_test.go +++ b/cmd/plugin_install_test.go @@ -12,6 +12,8 @@ import ( func Test_pluginInstallCmd(t *testing.T) { pluginTestConfigFile := "./test_plugins_pluginInstallCmd.yaml" + // TODO: hack + App.PluginConfigFile = pluginTestConfigFile // Create a test plugin config file. output, err := executeCommandC(rootCmd, "plugin", "init", "-p", pluginTestConfigFile) diff --git a/cmd/plugin_list_test.go b/cmd/plugin_list_test.go index a1d51e80..dd16c806 100644 --- a/cmd/plugin_list_test.go +++ b/cmd/plugin_list_test.go @@ -11,6 +11,9 @@ import ( func Test_pluginListCmd(t *testing.T) { pluginTestConfigFile := "./test_plugins_pluginListCmd.yaml" + // TODO: Hack to ensure the plugin config file is created before running the plugin list command. REMOVE THIS HACK. + App.PluginConfigFile = pluginTestConfigFile + // Test plugin list command. output, err := executeCommandC(rootCmd, "plugin", "init", "-p", pluginTestConfigFile) require.NoError(t, err, "plugin init command should not have returned an error") @@ -36,6 +39,9 @@ func Test_pluginListCmdWithPlugins(t *testing.T) { // Test plugin list command. // Read the plugin config file from the root directory. pluginTestConfigFile := "../gatewayd_plugins.yaml" + // TODO: Hack to ensure the plugin config file is created before running the plugin list command. REMOVE THIS HACK. + App.PluginConfigFile = pluginTestConfigFile + output, err := executeCommandC(rootCmd, "plugin", "list", "-p", pluginTestConfigFile) require.NoError(t, err, "plugin list command should not have returned an error") assert.Contains(t,