github.com/lologarithm/mattermost-server@v5.3.2-0.20181002060438-c82a84ed765b+incompatible/app/command_code_test.go (about)

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