github.com/mattermost/mattermost-server/v5@v5.39.3/api4/command_help_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package api4
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  
    11  	"github.com/mattermost/mattermost-server/v5/model"
    12  )
    13  
    14  func TestHelpCommand(t *testing.T) {
    15  	th := Setup(t).InitBasic()
    16  	defer th.TearDown()
    17  
    18  	Client := th.Client
    19  	channel := th.BasicChannel
    20  
    21  	HelpLink := *th.App.Config().SupportSettings.HelpLink
    22  	defer func() {
    23  		th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = HelpLink })
    24  	}()
    25  
    26  	th.App.UpdateConfig(func(cfg *model.Config) { *cfg.SupportSettings.HelpLink = "" })
    27  	rs1, _ := Client.ExecuteCommand(channel.Id, "/help ")
    28  	assert.Equal(t, rs1.GotoLocation, model.SUPPORT_SETTINGS_DEFAULT_HELP_LINK, "failed to default help link")
    29  
    30  	th.App.UpdateConfig(func(cfg *model.Config) {
    31  		*cfg.SupportSettings.HelpLink = "https://docs.mattermost.com/guides/user.html"
    32  	})
    33  	rs2, _ := Client.ExecuteCommand(channel.Id, "/help ")
    34  	assert.Equal(t, rs2.GotoLocation, "https://docs.mattermost.com/guides/user.html", "failed to help link")
    35  }