Skip to content

Commit

Permalink
Revert "Fix default DSN tests manually setting the env variable from …
Browse files Browse the repository at this point in the history
…mainHelper"

This reverts commit 13545bb.
  • Loading branch information
isacikgoz committed Mar 22, 2023
1 parent 59f943c commit 1f63b7b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 34 deletions.
7 changes: 0 additions & 7 deletions server/channels/app/platform/cluster_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
package platform

import (
"os"
"testing"
"time"

"github.com/mattermost/mattermost-server/v6/model"
)

func TestClusterDiscoveryService(t *testing.T) {
// TODO: this needs to be refactored so the env variable doesn't
// need to be set here
os.Setenv("MM_SQLSETTINGS_DATASOURCE", *mainHelper.Settings.DataSource)

th := Setup(t)
defer th.TearDown()

Expand All @@ -29,6 +24,4 @@ func TestClusterDiscoveryService(t *testing.T) {

ds.Stop()
time.Sleep(2 * time.Second)

os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
}
6 changes: 0 additions & 6 deletions server/channels/app/plugin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,10 +1159,6 @@ func pluginAPIHookTest(t *testing.T, th *TestHelper, fileName string, id string,
// 5. Successfully running test should return nil, "OK". Any other returned string is considered and error

func TestBasicAPIPlugins(t *testing.T) {
// TODO: this needs to be refactored so the env variable doesn't
// need to be set here
os.Setenv("MM_SQLSETTINGS_DATASOURCE", *mainHelper.Settings.DataSource)

defaultSchema := getDefaultPluginSettingsSchema()
testFolder, found := fileutils.FindDir("mattermost-server/server/channels/app/plugin_api_tests")
require.True(t, found, "Cannot read find app folder")
Expand All @@ -1183,8 +1179,6 @@ func TestBasicAPIPlugins(t *testing.T) {
})
}
}

os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
}

func TestPluginAPIKVCompareAndSet(t *testing.T) {
Expand Down
8 changes: 0 additions & 8 deletions server/channels/app/product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package app

import (
"os"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -40,18 +39,13 @@ func (p *productB) Start() error { return nil }
func (p *productB) Stop() error { return nil }

func TestInitializeProducts(t *testing.T) {
// TODO: this needs to be refactored so the env variable doesn't
// need to be set here
os.Setenv("MM_SQLSETTINGS_DATASOURCE", *mainHelper.Settings.DataSource)

cs := config.NewTestMemoryStore()
cfg := cs.Get()
cfg.FeatureFlags.BoardsProduct = false
cs.Set(cfg)

ps, err := platform.New(platform.ServiceConfig{ConfigStore: cs})
require.NoError(t, err)
defer ps.Shutdown()

t.Run("2 products and no circular dependency", func(t *testing.T) {
serviceMap := map[product.ServiceKey]any{
Expand Down Expand Up @@ -179,6 +173,4 @@ func TestInitializeProducts(t *testing.T) {
require.NoError(t, err)
require.Len(t, server.products, 1)
})

os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
}
7 changes: 0 additions & 7 deletions server/channels/web/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package web
import (
"context"
"net/http"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -36,10 +35,6 @@ func TestRequireHookId(t *testing.T) {
}

func TestCloudKeyRequired(t *testing.T) {
// TODO: this needs to be refactored so the env variable doesn't
// need to be set here
os.Setenv("MM_SQLSETTINGS_DATASOURCE", *mainHelper.Settings.DataSource)

th := SetupWithStoreMock(t)
defer th.TearDown()

Expand All @@ -53,8 +48,6 @@ func TestCloudKeyRequired(t *testing.T) {
c.CloudKeyRequired()

assert.Equal(t, c.Err.Id, "api.context.session_expired.app_error")

os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
}

func TestMfaRequired(t *testing.T) {
Expand Down
6 changes: 0 additions & 6 deletions server/cmd/mattermost/commands/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ func (th *ServerTestHelper) TearDownServerTest() {
}

func TestRunServerSuccess(t *testing.T) {
// TODO: this needs to be refactored so the env variable doesn't
// need to be set here
os.Setenv("MM_SQLSETTINGS_DATASOURCE", *mainHelper.Settings.DataSource)

th := SetupServerTest(t)
defer th.TearDownServerTest()

Expand All @@ -73,8 +69,6 @@ func TestRunServerSuccess(t *testing.T) {

err := runServer(configStore, th.interruptChan)
require.NoError(t, err)

os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
}

func TestRunServerSystemdNotification(t *testing.T) {
Expand Down

0 comments on commit 1f63b7b

Please sign in to comment.