summaryrefslogtreecommitdiffstats
path: root/app/config_test.go
diff options
context:
space:
mode:
authorHanzei <16541325+hanzei@users.noreply.github.com>2018-10-05 18:24:02 +0200
committerJesse Hallam <jesse.hallam@gmail.com>2018-10-05 12:24:02 -0400
commit7b338c161bce8bdede54d85a5df5a0efe34eb874 (patch)
treec78040d86cef9d8fde6f35d1a2aee553a746c8be /app/config_test.go
parent0a68e741d07d086ca3a94c73a958cb9fa3c50943 (diff)
downloadchat-7b338c161bce8bdede54d85a5df5a0efe34eb874.tar.gz
chat-7b338c161bce8bdede54d85a5df5a0efe34eb874.tar.bz2
chat-7b338c161bce8bdede54d85a5df5a0efe34eb874.zip
MM-12323: Fix trailing slash in ServiceSettings.SiteURL (#9463)
* Fix trailing slash in ServiceSettings.SiteURL * Add test for LoadConfig * Fix test * Simplify test
Diffstat (limited to 'app/config_test.go')
-rw-r--r--app/config_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/config_test.go b/app/config_test.go
index abaf00167..1c1811b94 100644
--- a/app/config_test.go
+++ b/app/config_test.go
@@ -4,17 +4,45 @@
package app
import (
+ "io/ioutil"
"strconv"
+ "strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store/sqlstore"
"github.com/mattermost/mattermost-server/utils"
)
+func TestLoadConfig(t *testing.T) {
+ tempConfig, err := ioutil.TempFile("", "")
+ require.Nil(t, err)
+
+ input, err := ioutil.ReadFile(utils.FindConfigFile("config.json"))
+ require.Nil(t, err)
+ lines := strings.Split(string(input), "\n")
+ for i, line := range lines {
+ if strings.Contains(line, "SiteURL") {
+ lines[i] = ` "SiteURL": "http://localhost:8065/",`
+ }
+ }
+ output := strings.Join(lines, "\n")
+ err = ioutil.WriteFile(tempConfig.Name(), []byte(output), 0644)
+ require.Nil(t, err)
+ tempConfig.Close()
+
+ a := App{}
+ appErr := a.LoadConfig(tempConfig.Name())
+ require.Nil(t, appErr)
+
+ assert.Equal(t, "http://localhost:8065", a.siteURL)
+ assert.Equal(t, "http://localhost:8065", *a.GetConfig().ServiceSettings.SiteURL)
+}
+
func TestConfigListener(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()