Migrate tests from "cmd/mattermost/commands/roles_test.go" to… (#12421)

* migrated tests in roles_test.go to use testify

* format file

* format file and edit some test statements

* change some require statements to assert

* remove extra t.Fatal

* test error on response

* use require.NotEmpty
Этот коммит содержится в:
Phillip Ahereza
2019-10-08 17:39:44 +03:00
коммит произвёл jfrerich
родитель 894b124bc6
Коммит d290534297
2 изменённых файлов: 15 добавлений и 19 удалений

Просмотреть файл

@@ -114,16 +114,17 @@ func TestCreateCommand(t *testing.T) {
t.Run(testCase.Description, func(t *testing.T) {
actual, _ := th.RunCommandWithOutput(t, testCase.Args...)
cmds, _ := th.SystemAdminClient.ListCommands(team.Id, true)
cmds, response := th.SystemAdminClient.ListCommands(team.Id, true)
require.Nil(t, response.Error, "Failed to list commands")
if testCase.ExpectedErr == "" {
if len(cmds) == 0 || cmds[0].Trigger != "testcmd" {
t.Fatal("Failed to create command")
}
require.NotEmpty(t, cmds, "Failed to create command")
require.Equal(t, "testcmd", cmds[0].Trigger)
assert.Contains(t, string(actual), "PASS")
} else {
if len(cmds) > 1 {
t.Fatal("Created command that shouldn't have been created")
require.Fail(t, "Created command that shouldn't have been created")
}
assert.Contains(t, string(actual), testCase.ExpectedErr)
}