mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Fixed app.CreateUser not using the provided locale * Added initial unit tests for cmd package * Disabled unit tests while we move to 'go build'
59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mattermost/platform/app"
|
|
"github.com/mattermost/platform/model"
|
|
)
|
|
|
|
func TestGetUserFromUserArg(t *testing.T) {
|
|
th := app.Setup().InitBasic()
|
|
|
|
user := th.BasicUser
|
|
|
|
if found := getUserFromUserArg(""); found != nil {
|
|
t.Fatal("shoudn't have gotten a user", found)
|
|
}
|
|
|
|
if found := getUserFromUserArg(model.NewId()); found != nil {
|
|
t.Fatal("shoudn't have gotten a user", found)
|
|
}
|
|
|
|
if found := getUserFromUserArg(user.Id); found == nil || found.Id != user.Id {
|
|
t.Fatal("got incorrect user", found)
|
|
}
|
|
|
|
if found := getUserFromUserArg(user.Username); found == nil || found.Id != user.Id {
|
|
t.Fatal("got incorrect user", found)
|
|
}
|
|
}
|
|
|
|
func TestGetUsersFromUserArg(t *testing.T) {
|
|
th := app.Setup().InitBasic()
|
|
|
|
user := th.BasicUser
|
|
user2 := th.CreateUser()
|
|
|
|
if found := getUsersFromUserArgs([]string{}); len(found) != 0 {
|
|
t.Fatal("shoudn't have gotten any users", found)
|
|
}
|
|
|
|
if found := getUsersFromUserArgs([]string{user.Id}); len(found) == 1 && found[0].Id != user.Id {
|
|
t.Fatal("got incorrect user", found)
|
|
}
|
|
|
|
if found := getUsersFromUserArgs([]string{user2.Username}); len(found) == 1 && found[0].Id != user2.Id {
|
|
t.Fatal("got incorrect user", found)
|
|
}
|
|
|
|
if found := getUsersFromUserArgs([]string{user.Username, user2.Id}); len(found) != 2 {
|
|
t.Fatal("got incorrect number of users", found)
|
|
} else if !(found[0].Id == user.Id && found[1].Id == user2.Id) && !(found[1].Id == user.Id && found[0].Id == user2.Id) {
|
|
t.Fatal("got incorrect users", found[0], found[1])
|
|
}
|
|
}
|