summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-09-29 12:46:30 -0700
committerGitHub <noreply@github.com>2017-09-29 12:46:30 -0700
commitb84736e9b6401df0c6eeab9950bef09458a6aefd (patch)
treed9175208de3236db75a33879750a57b3000ba096 /cmd
parent8b9dbb86133ff0fd6002a391268383d1593918ca (diff)
downloadchat-b84736e9b6401df0c6eeab9950bef09458a6aefd.tar.gz
chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.tar.bz2
chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.zip
Updating server dependancies. (#7538)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/platform/channelargs_test.go.disabled106
-rw-r--r--cmd/platform/teamargs_test.go.disabled58
-rw-r--r--cmd/platform/user_test.go.disabled212
-rw-r--r--cmd/platform/userargs_test.go.disabled58
4 files changed, 0 insertions, 434 deletions
diff --git a/cmd/platform/channelargs_test.go.disabled b/cmd/platform/channelargs_test.go.disabled
deleted file mode 100644
index 5447a061d..000000000
--- a/cmd/platform/channelargs_test.go.disabled
+++ /dev/null
@@ -1,106 +0,0 @@
-// 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 TestParseChannelArg(t *testing.T) {
- if team, channel := parseChannelArg("channel"); team != "" {
- t.Fatal("got incorrect team", team)
- } else if channel != "channel" {
- t.Fatal("got incorrect channel", channel)
- }
-
- if team, channel := parseChannelArg("team:channel"); team != "team" {
- t.Fatal("got incorrect team", team)
- } else if channel != "channel" {
- t.Fatal("got incorrect channel", channel)
- }
-}
-
-func TestGetChannelFromChannelArg(t *testing.T) {
- th := app.Setup().InitBasic()
-
- team := th.BasicTeam
- channel := th.BasicChannel
-
- if found := getChannelFromChannelArg(""); found != nil {
- t.Fatal("shoudn't have gotten a channel", found)
- }
-
- if found := getChannelFromChannelArg(channel.Id); found == nil || found.Id != channel.Id {
- t.Fatal("got incorrect channel", found)
- }
-
- if found := getChannelFromChannelArg(model.NewId()); found != nil {
- t.Fatal("shouldn't have gotten a channel that doesn't exist", found)
- }
-
- if found := getChannelFromChannelArg(channel.Name); found != nil {
- t.Fatal("shouldn't have gotten a channel by name without team", found)
- }
-
- if found := getChannelFromChannelArg(team.Id + ":" + channel.Name); found == nil || found.Id != channel.Id {
- t.Fatal("got incorrect channel", found)
- }
-
- if found := getChannelFromChannelArg(team.Name + ":" + channel.Name); found == nil || found.Id != channel.Id {
- t.Fatal("got incorrect channel", found)
- }
-
- if found := getChannelFromChannelArg(team.Name + ":" + channel.Id); found == nil || found.Id != channel.Id {
- t.Fatal("got incorrect channel", found)
- }
-
- if found := getChannelFromChannelArg("notateam" + ":" + channel.Name); found != nil {
- t.Fatal("shouldn't have gotten a channel by name on incorrect team", found)
- }
-
- if found := getChannelFromChannelArg(team.Name + ":" + "notachannel"); found != nil {
- t.Fatal("shouldn't have gotten a channel that doesn't exist", found)
- }
-}
-
-func TestGetChannelsFromChannelArg(t *testing.T) {
- th := app.Setup().InitBasic()
-
- team := th.BasicTeam
- channel := th.BasicChannel
- channel2 := th.CreateChannel(team)
-
- if found := getChannelsFromChannelArgs([]string{}); len(found) != 0 {
- t.Fatal("shoudn't have gotten any channels", found)
- }
-
- if found := getChannelsFromChannelArgs([]string{channel.Id}); len(found) == 1 && found[0].Id != channel.Id {
- t.Fatal("got incorrect channel", found)
- }
-
- if found := getChannelsFromChannelArgs([]string{team.Name + ":" + channel2.Name}); len(found) == 1 && found[0].Id != channel2.Id {
- t.Fatal("got incorrect channel", found)
- }
-
- if found := getChannelsFromChannelArgs([]string{team.Name + ":" + channel.Name, team.Name + ":" + channel2.Name}); len(found) != 2 {
- t.Fatal("got incorrect number of channels", found)
- } else if !(found[0].Id == channel.Id && found[1].Id == channel2.Id) && !(found[1].Id == channel.Id && found[0].Id == channel2.Id) {
- t.Fatal("got incorrect channels", found[0], found[1])
- }
-
- if found := getChannelsFromChannelArgs([]string{channel.Id, channel2.Id}); len(found) != 2 {
- t.Fatal("got incorrect number of channels", found)
- } else if !(found[0].Id == channel.Id && found[1].Id == channel2.Id) && !(found[1].Id == channel.Id && found[0].Id == channel2.Id) {
- t.Fatal("got incorrect channels", found[0], found[1])
- }
-
- if found := getChannelsFromChannelArgs([]string{channel.Id, team.Name + ":" + channel2.Name}); len(found) != 2 {
- t.Fatal("got incorrect number of channels", found)
- } else if !(found[0].Id == channel.Id && found[1].Id == channel2.Id) && !(found[1].Id == channel.Id && found[0].Id == channel2.Id) {
- t.Fatal("got incorrect channels", found[0], found[1])
- }
-}
diff --git a/cmd/platform/teamargs_test.go.disabled b/cmd/platform/teamargs_test.go.disabled
deleted file mode 100644
index 573ec8a99..000000000
--- a/cmd/platform/teamargs_test.go.disabled
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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])
- }
-}
diff --git a/cmd/platform/user_test.go.disabled b/cmd/platform/user_test.go.disabled
deleted file mode 100644
index 4119574f3..000000000
--- a/cmd/platform/user_test.go.disabled
+++ /dev/null
@@ -1,212 +0,0 @@
-// 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 TestChangeUserActiveStatus(t *testing.T) {
- th := app.Setup().InitBasic()
-
- user := th.BasicUser
-
- if err := changeUserActiveStatus(nil, "user", false); err == nil {
- t.Fatal("should've returned error when user doesn't exist")
- }
-
- if err := changeUserActiveStatus(user, user.Username, false); err != nil {
- t.Fatal(err)
- } else if user, _ = app.GetUser(user.Id); user.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- }
-
- if err := changeUserActiveStatus(user, user.Username, true); err != nil {
- t.Fatal(err)
- } else if user, _ := app.GetUser(user.Id); user.DeleteAt != 0 {
- t.Fatal("should've activated user")
- }
-}
-
-func TestChangeUsersActiveStatus(t *testing.T) {
- th := app.Setup().InitBasic()
-
- user := th.BasicUser
- user2 := th.CreateUser()
-
- changeUsersActiveStatus([]string{user.Username, user2.Id}, false)
-
- if user, _ = app.GetUser(user.Id); user.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- } else if user2, _ = app.GetUser(user2.Id); user2.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- }
-
- changeUsersActiveStatus([]string{user.Username, user2.Id}, true)
-
- if user, _ = app.GetUser(user.Id); user.DeleteAt != 0 {
- t.Fatal("should've activated user")
- } else if user2, _ = app.GetUser(user2.Id); user2.DeleteAt != 0 {
- t.Fatal("should've activated user")
- }
-}
-
-func TestUserActivateDeactivateCmdF(t *testing.T) {
- th := app.Setup().InitBasic()
-
- user := th.BasicUser
- user2 := th.CreateUser()
-
- userDeactivateCmdF(userDeactivateCmd, []string{user.Username, user2.Id})
-
- if user, _ = app.GetUser(user.Id); user.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- } else if user2, _ = app.GetUser(user2.Id); user2.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- }
-
- userActivateCmdF(userActivateCmd, []string{user.Username, user2.Id})
-
- if user, _ = app.GetUser(user.Id); user.DeleteAt != 0 {
- t.Fatal("should've activated user")
- } else if user2, _ = app.GetUser(user2.Id); user2.DeleteAt != 0 {
- t.Fatal("should've activated user")
- }
-}
-
-func TestUserActivateDeactivateCmd(t *testing.T) {
- th := app.Setup().InitBasic()
-
- user := th.BasicUser
- user2 := th.CreateUser()
-
- if err := runCommand("user deactivate " + user.Username + " " + user2.Id); err != nil {
- t.Fatal(err)
- } else if user, _ = app.GetUser(user.Id); user.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- } else if user2, _ = app.GetUser(user2.Id); user2.DeleteAt == 0 {
- t.Fatal("should've deactivated user")
- }
-
- if err := runCommand("user activate " + user.Id + " " + user2.Username); err != nil {
- t.Fatal(err)
- } else if user, _ = app.GetUser(user.Id); user.DeleteAt != 0 {
- t.Fatal("should've activated user")
- } else if user2, _ = app.GetUser(user2.Id); user2.DeleteAt != 0 {
- t.Fatal("should've activated user")
- }
-}
-
-func TestUserCreateCmd(t *testing.T) {
- th := app.Setup().InitBasic()
-
- if err := runCommand("user create"); err == nil {
- t.Fatal("should've failed without any arguments")
- }
-
- username := th.MakeUsername()
- email := th.MakeEmail()
- if err := runCommand("user create --username " + username + " --email " + email + " --password " + model.NewId()); err != nil {
- t.Fatal(err)
- } else if user, err := app.GetUserByUsername(username); err != nil {
- t.Fatal(err.Message)
- } else if user.Username != username {
- t.Fatal("should've set correct username")
- } else if user.Email != email {
- t.Fatal("should've set correct email")
- }
-
- username = th.MakeUsername()
- nickname := model.NewId()
- firstName := model.NewId()
- lastName := model.NewId()
- locale := "fr"
- if err := runCommand("user create --username " + username + " --email " + th.MakeEmail() + " --password " + model.NewId() +
- " --nickname " + nickname + " --firstname " + firstName + " --lastname " + lastName + " --locale " + locale); err != nil {
- t.Fatal(err)
- } else if user, err := app.GetUserByUsername(username); err != nil {
- t.Fatal(err)
- } else if user.Nickname != nickname {
- t.Fatal("should've set correct nickname")
- } else if user.FirstName != firstName {
- t.Fatal("should've set correct first name")
- } else if user.LastName != lastName {
- t.Fatal("should've set correct last name")
- } else if user.Locale != locale {
- t.Fatal("should've set correct locale", user.Locale)
- } else if user.Roles != "system_user" {
- t.Fatal("should've set correct roles for user")
- }
-
- username = th.MakeUsername()
- if err := runCommand("user create --username " + username + " --email " + th.MakeEmail() + " --password " + model.NewId() + " --system_admin"); err != nil {
- t.Fatal(err)
- } else if user, err := app.GetUserByUsername(username); err != nil {
- t.Fatal(err)
- } else if user.Roles != "system_user system_admin" {
- t.Fatal("should've set correct roles for system admin")
- }
-
- if err := runCommand("user create --email " + th.MakeEmail() + " --password " + model.NewId()); err == nil {
- t.Fatal("should've failed without username")
- }
-
- if err := runCommand("user create --username " + th.MakeUsername() + " --email " + th.MakeEmail()); err == nil {
- t.Fatal("should've failed without password")
- }
-
- if err := runCommand("user create --username " + th.MakeUsername() + " --password " + model.NewId()); err == nil {
- t.Fatal("should've failed without email")
- }
-}
-
-func TestInviteUser(t *testing.T) {
- th := app.Setup().InitBasic()
-
- team := th.CreateTeam()
-
- if err := inviteUser(th.MakeEmail(), nil, "faketeam"); err == nil {
- t.Fatal("should've failed with nonexistent team")
- }
-
- if err := inviteUser(th.MakeEmail(), team, team.Name); err != nil {
- t.Fatal(err)
- }
-
- // Nothing else to test here since this just fires off an email
-}
-
-func TestUserInviteCmd(t *testing.T) {
- th := app.Setup().InitBasic()
-
- team := th.BasicTeam
- team2 := th.CreateTeam()
-
- if err := runCommand("user invite"); err == nil {
- t.Fatal("should've failed without any arguments")
- }
-
- if err := runCommand("user invite " + th.MakeEmail()); err == nil {
- t.Fatal("should've failed with 1 argument")
- }
-
- if err := runCommand("user invite " + th.MakeEmail() + " " + team.Id); err != nil {
- t.Fatal(err)
- }
-
- if err := runCommand("user invite " + th.MakeEmail() + " " + team.Name); err != nil {
- t.Fatal(err)
- }
-
- if err := runCommand("user invite " + th.MakeEmail() + " " + team.Id + " " + team2.Name); err != nil {
- t.Fatal(err)
- }
-
- if err := runCommand("user invite " + th.MakeEmail() + " " + team.Id + " " + team2.Name + " " + "faketeam"); err != nil {
- t.Fatal(err)
- }
-}
diff --git a/cmd/platform/userargs_test.go.disabled b/cmd/platform/userargs_test.go.disabled
deleted file mode 100644
index 2b6a50bb8..000000000
--- a/cmd/platform/userargs_test.go.disabled
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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])
- }
-}