From 345dd400bbe2f41c45b08dc06e3199c900361fff Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 24 Jul 2017 11:55:37 -0700 Subject: PLT-6706: add /code command (#6936) * add /code command * return an error for empty /code message --- app/command_code_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/command_code_test.go (limited to 'app/command_code_test.go') diff --git a/app/command_code_test.go b/app/command_code_test.go new file mode 100644 index 000000000..7b5813a62 --- /dev/null +++ b/app/command_code_test.go @@ -0,0 +1,26 @@ +package app + +import ( + "testing" + + "github.com/mattermost/platform/model" +) + +func TestCodeProviderDoCommand(t *testing.T) { + cp := CodeProvider{} + args := &model.CommandArgs{ + T: func(s string, args ...interface{}) string { return s }, + } + + for msg, expected := range map[string]string{ + "": "api.command_code.message.app_error", + "foo": " foo", + "foo\nbar": " foo\n bar", + "foo\nbar\n": " foo\n bar\n ", + } { + actual := cp.DoCommand(args, msg).Text + if actual != expected { + t.Errorf("expected `%v`, got `%v`", expected, actual) + } + } +} -- cgit v1.2.3-1-g7c22