app type transition (#7167)
Этот коммит содержится в:
@@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
|
||||
id := model.NewId()
|
||||
team := &model.Team{
|
||||
@@ -21,18 +22,19 @@ func TestCreateTeam(t *testing.T) {
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
|
||||
if _, err := CreateTeam(team); err != nil {
|
||||
if _, err := a.CreateTeam(team); err != nil {
|
||||
t.Log(err)
|
||||
t.Fatal("Should create a new team")
|
||||
}
|
||||
|
||||
if _, err := CreateTeam(th.BasicTeam); err == nil {
|
||||
if _, err := a.CreateTeam(th.BasicTeam); err == nil {
|
||||
t.Fatal("Should not create a new team - team already exist")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateTeamWithUser(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
|
||||
id := model.NewId()
|
||||
team := &model.Team{
|
||||
@@ -42,17 +44,17 @@ func TestCreateTeamWithUser(t *testing.T) {
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
|
||||
if _, err := CreateTeamWithUser(team, th.BasicUser.Id); err != nil {
|
||||
if _, err := a.CreateTeamWithUser(team, th.BasicUser.Id); err != nil {
|
||||
t.Log(err)
|
||||
t.Fatal("Should create a new team with existing user")
|
||||
}
|
||||
|
||||
if _, err := CreateTeamWithUser(team, model.NewId()); err == nil {
|
||||
if _, err := a.CreateTeamWithUser(team, model.NewId()); err == nil {
|
||||
t.Fatal("Should not create a new team - user does not exist")
|
||||
}
|
||||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := CreateUser(&user)
|
||||
ruser, _ := a.CreateUser(&user)
|
||||
|
||||
id = model.NewId()
|
||||
team2 := &model.Team{
|
||||
@@ -63,7 +65,7 @@ func TestCreateTeamWithUser(t *testing.T) {
|
||||
}
|
||||
|
||||
//Fail to create a team with user when user has set email without domain
|
||||
if _, err := CreateTeamWithUser(team2, ruser.Id); err == nil {
|
||||
if _, err := a.CreateTeamWithUser(team2, ruser.Id); err == nil {
|
||||
t.Log(err.Message)
|
||||
t.Fatal("Should not create a team with user when user has set email without domain")
|
||||
} else {
|
||||
@@ -75,11 +77,12 @@ func TestCreateTeamWithUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
|
||||
th.BasicTeam.DisplayName = "Testing 123"
|
||||
|
||||
if updatedTeam, err := UpdateTeam(th.BasicTeam); err != nil {
|
||||
if updatedTeam, err := a.UpdateTeam(th.BasicTeam); err != nil {
|
||||
t.Log(err)
|
||||
t.Fatal("Should update the team")
|
||||
} else {
|
||||
@@ -90,33 +93,36 @@ func TestUpdateTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddUserToTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := CreateUser(&user)
|
||||
ruser, _ := a.CreateUser(&user)
|
||||
|
||||
if _, err := AddUserToTeam(th.BasicTeam.Id, ruser.Id, ""); err != nil {
|
||||
if _, err := a.AddUserToTeam(th.BasicTeam.Id, ruser.Id, ""); err != nil {
|
||||
t.Log(err)
|
||||
t.Fatal("Should add user to the team")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddUserToTeamByTeamId(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := CreateUser(&user)
|
||||
ruser, _ := a.CreateUser(&user)
|
||||
|
||||
if err := AddUserToTeamByTeamId(th.BasicTeam.Id, ruser); err != nil {
|
||||
if err := a.AddUserToTeamByTeamId(th.BasicTeam.Id, ruser); err != nil {
|
||||
t.Log(err)
|
||||
t.Fatal("Should add user to the team")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPermanentDeleteTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
|
||||
team, err := CreateTeam(&model.Team{
|
||||
team, err := a.CreateTeam(&model.Team{
|
||||
DisplayName: "deletion-test",
|
||||
Name: "deletion-test",
|
||||
Email: "foo@foo.com",
|
||||
@@ -126,10 +132,10 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer func() {
|
||||
PermanentDeleteTeam(team)
|
||||
a.PermanentDeleteTeam(team)
|
||||
}()
|
||||
|
||||
command, err := CreateCommand(&model.Command{
|
||||
command, err := a.CreateCommand(&model.Command{
|
||||
CreatorId: th.BasicUser.Id,
|
||||
TeamId: team.Id,
|
||||
Trigger: "foo",
|
||||
@@ -139,37 +145,37 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer DeleteCommand(command.Id)
|
||||
defer a.DeleteCommand(command.Id)
|
||||
|
||||
if command, err = GetCommand(command.Id); command == nil || err != nil {
|
||||
if command, err = a.GetCommand(command.Id); command == nil || err != nil {
|
||||
t.Fatal("unable to get new command")
|
||||
}
|
||||
|
||||
if err := PermanentDeleteTeam(team); err != nil {
|
||||
if err := a.PermanentDeleteTeam(team); err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
if command, err = GetCommand(command.Id); command != nil || err == nil {
|
||||
if command, err = a.GetCommand(command.Id); command != nil || err == nil {
|
||||
t.Fatal("command wasn't deleted")
|
||||
}
|
||||
|
||||
// Test deleting a team with no channels.
|
||||
team = th.CreateTeam()
|
||||
defer func() {
|
||||
PermanentDeleteTeam(team)
|
||||
a.PermanentDeleteTeam(team)
|
||||
}()
|
||||
|
||||
if channels, err := GetPublicChannelsForTeam(team.Id, 0, 1000); err != nil {
|
||||
if channels, err := a.GetPublicChannelsForTeam(team.Id, 0, 1000); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
for _, channel := range *channels {
|
||||
if err2 := PermanentDeleteChannel(channel); err2 != nil {
|
||||
if err2 := a.PermanentDeleteChannel(channel); err2 != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := PermanentDeleteTeam(team); err != nil {
|
||||
if err := a.PermanentDeleteTeam(team); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user