diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2017-04-15 13:45:22 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-04-15 13:45:22 -0400 |
commit | 461a0b3b7c14cd59cb53eb66f419c965ab3bdd24 (patch) | |
tree | 88eea69d8963214fa43e8bf1a9989f2ab3d1c521 /cmd/platform/teamargs_test.go.disabled | |
parent | 24667e3e5423dc939770d0b4bf06ed2f42b4a445 (diff) | |
download | chat-461a0b3b7c14cd59cb53eb66f419c965ab3bdd24.tar.gz chat-461a0b3b7c14cd59cb53eb66f419c965ab3bdd24.tar.bz2 chat-461a0b3b7c14cd59cb53eb66f419c965ab3bdd24.zip |
PLT-6113 Added initial unit tests for cmd package (#6086)
* Fixed app.CreateUser not using the provided locale
* Added initial unit tests for cmd package
* Disabled unit tests while we move to 'go build'
Diffstat (limited to 'cmd/platform/teamargs_test.go.disabled')
-rw-r--r-- | cmd/platform/teamargs_test.go.disabled | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cmd/platform/teamargs_test.go.disabled b/cmd/platform/teamargs_test.go.disabled new file mode 100644 index 000000000..573ec8a99 --- /dev/null +++ b/cmd/platform/teamargs_test.go.disabled @@ -0,0 +1,58 @@ +// 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 TestGetTeamFromTeamArg(t *testing.T) { + th := app.Setup().InitBasic() + + team := th.BasicTeam + + if found := getTeamFromTeamArg(""); found != nil { + t.Fatal("shoudn't have gotten a team", found) + } + + if found := getTeamFromTeamArg(model.NewId()); found != nil { + t.Fatal("shoudn't have gotten a team", found) + } + + if found := getTeamFromTeamArg(team.Id); found == nil || found.Id != team.Id { + t.Fatal("got incorrect team", found) + } + + if found := getTeamFromTeamArg(team.Name); found == nil || found.Id != team.Id { + t.Fatal("got incorrect team", found) + } +} + +func TestGetTeamsFromTeamArg(t *testing.T) { + th := app.Setup().InitBasic() + + team := th.BasicTeam + team2 := th.CreateTeam() + + if found := getTeamsFromTeamArgs([]string{}); len(found) != 0 { + t.Fatal("shoudn't have gotten any teams", found) + } + + if found := getTeamsFromTeamArgs([]string{team.Id}); len(found) == 1 && found[0].Id != team.Id { + t.Fatal("got incorrect team", found) + } + + if found := getTeamsFromTeamArgs([]string{team2.Name}); len(found) == 1 && found[0].Id != team2.Id { + t.Fatal("got incorrect team", found) + } + + if found := getTeamsFromTeamArgs([]string{team.Name, team2.Id}); len(found) != 2 { + t.Fatal("got incorrect number of teams", found) + } else if !(found[0].Id == team.Id && found[1].Id == team2.Id) && !(found[1].Id == team.Id && found[0].Id == team2.Id) { + t.Fatal("got incorrect teams", found[0], found[1]) + } +} |