github.com/mattermosttest/mattermost-server/v5@v5.0.0-20200917143240-9dfa12e121f9/app/command_code_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package app
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/mattermost/mattermost-server/v5/model"
    10  )
    11  
    12  func TestCodeProviderDoCommand(t *testing.T) {
    13  	cp := CodeProvider{}
    14  	args := &model.CommandArgs{
    15  		T: func(s string, args ...interface{}) string { return s },
    16  	}
    17  
    18  	for msg, expected := range map[string]string{
    19  		"":           "api.command_code.message.app_error",
    20  		"foo":        "    foo",
    21  		"foo\nbar":   "    foo\n    bar",
    22  		"foo\nbar\n": "    foo\n    bar\n    ",
    23  	} {
    24  		actual := cp.DoCommand(nil, args, msg).Text
    25  		if actual != expected {
    26  			t.Errorf("expected `%v`, got `%v`", expected, actual)
    27  		}
    28  	}
    29  }