summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
Diffstat (limited to 'api4')
-rw-r--r--api4/apitestlib.go11
-rw-r--r--api4/command_test.go7
2 files changed, 12 insertions, 6 deletions
diff --git a/api4/apitestlib.go b/api4/apitestlib.go
index 80a44c13f..640f38fe6 100644
--- a/api4/apitestlib.go
+++ b/api4/apitestlib.go
@@ -81,6 +81,10 @@ func setupTestHelper(enterprise bool) *TestHelper {
var options []app.Option
if testStore != nil {
options = append(options, app.StoreOverride(testStore))
+ options = append(options, app.ConfigOverride(func(cfg *model.Config) {
+ cfg.ServiceSettings.ListenAddress = new(string)
+ *cfg.ServiceSettings.ListenAddress = ":0"
+ }))
}
th := &TestHelper{
@@ -221,8 +225,9 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
func (me *TestHelper) waitForConnectivity() {
for i := 0; i < 1000; i++ {
- _, err := net.Dial("tcp", "localhost"+*utils.Cfg.ServiceSettings.ListenAddress)
+ conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%v", me.App.Srv.ListenAddr.Port))
if err == nil {
+ conn.Close()
return
}
time.Sleep(time.Millisecond * 20)
@@ -231,11 +236,11 @@ func (me *TestHelper) waitForConnectivity() {
}
func (me *TestHelper) CreateClient() *model.Client4 {
- return model.NewAPIv4Client("http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress)
+ return model.NewAPIv4Client(fmt.Sprintf("http://localhost:%v", me.App.Srv.ListenAddr.Port))
}
func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError) {
- return model.NewWebSocketClient4("ws://localhost"+*utils.Cfg.ServiceSettings.ListenAddress, me.Client.AuthToken)
+ return model.NewWebSocketClient4(fmt.Sprintf("ws://localhost:%v", me.App.Srv.ListenAddr.Port), me.Client.AuthToken)
}
func (me *TestHelper) CreateUser() *model.User {
diff --git a/api4/command_test.go b/api4/command_test.go
index 9a6c9dc78..52ef0f841 100644
--- a/api4/command_test.go
+++ b/api4/command_test.go
@@ -4,6 +4,7 @@
package api4
import (
+ "fmt"
"strings"
"testing"
@@ -399,7 +400,7 @@ func TestExecuteCommand(t *testing.T) {
postCmd := &model.Command{
CreatorId: th.BasicUser.Id,
TeamId: th.BasicTeam.Id,
- URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test",
+ URL: fmt.Sprintf("http://localhost:%v", th.App.Srv.ListenAddr.Port) + model.API_URL_SUFFIX_V4 + "/teams/command_test",
Method: model.COMMAND_METHOD_POST,
Trigger: "postcommand",
}
@@ -443,7 +444,7 @@ func TestExecuteCommand(t *testing.T) {
getCmd := &model.Command{
CreatorId: th.BasicUser.Id,
TeamId: th.BasicTeam.Id,
- URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test",
+ URL: fmt.Sprintf("http://localhost:%v", th.App.Srv.ListenAddr.Port) + model.API_URL_SUFFIX_V4 + "/teams/command_test",
Method: model.COMMAND_METHOD_GET,
Trigger: "getcommand",
}
@@ -511,7 +512,7 @@ func TestExecuteCommandAgainstChannelOnAnotherTeam(t *testing.T) {
postCmd := &model.Command{
CreatorId: th.BasicUser.Id,
TeamId: team2.Id,
- URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test",
+ URL: fmt.Sprintf("http://localhost:%v", th.App.Srv.ListenAddr.Port) + model.API_URL_SUFFIX_V4 + "/teams/command_test",
Method: model.COMMAND_METHOD_POST,
Trigger: "postcommand",
}