Commit f6e0310b authored by Saturnino Abril's avatar Saturnino Abril Committed by GitHub

[PLT-7390] Add Type = 'O' in getting open teams at sql store (#7207)

* add Type = 'O' in getting open teams at sql store

* updated PR
parent 7dad3965
......@@ -423,12 +423,20 @@ func TestGetAllTeams(t *testing.T) {
t.Fatal("wrong number of teams - should be 1")
}
// temporarily disable this test
/*for _, rt := range rrteams {
if rt.Type != model.TEAM_OPEN {
for _, rt := range rrteams {
if !rt.AllowOpenInvite {
t.Fatal("not all teams are open")
}
}*/
}
rrteams, resp = Client.GetAllTeams("", 0, 10)
CheckNoError(t, resp)
for _, rt := range rrteams {
if !rt.AllowOpenInvite {
t.Fatal("not all teams are open")
}
}
rrteams1, resp := Client.GetAllTeams("", 1, 0)
CheckNoError(t, resp)
......
......@@ -379,7 +379,7 @@ func TestTeamStoreByUserId(t *testing.T) {
}
}
func TestAllTeamListing(t *testing.T) {
func TestGetAllTeamListing(t *testing.T) {
Setup()
o1 := model.Team{}
......@@ -397,17 +397,130 @@ func TestAllTeamListing(t *testing.T) {
o2.Type = model.TEAM_OPEN
Must(store.Team().Save(&o2))
o3 := model.Team{}
o3.DisplayName = "DisplayName"
o3.Name = "z-z-z" + model.NewId() + "b"
o3.Email = model.NewId() + "@nowhere.com"
o3.Type = model.TEAM_INVITE
o3.AllowOpenInvite = true
Must(store.Team().Save(&o3))
o4 := model.Team{}
o4.DisplayName = "DisplayName"
o4.Name = "zz" + model.NewId() + "b"
o4.Email = model.NewId() + "@nowhere.com"
o4.Type = model.TEAM_INVITE
Must(store.Team().Save(&o4))
if r1 := <-store.Team().GetAllTeamListing(); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
for _, team := range teams {
if !team.AllowOpenInvite {
t.Fatal("should have returned team with AllowOpenInvite as true")
}
}
if len(teams) == 0 {
t.Fatal("failed team listing")
}
}
}
func TestGetAllTeamPageListing(t *testing.T) {
Setup()
o1 := model.Team{}
o1.DisplayName = "DisplayName"
o1.Name = "z-z-z" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
o1.AllowOpenInvite = true
Must(store.Team().Save(&o1))
o2 := model.Team{}
o2.DisplayName = "DisplayName"
o2.Name = "zz" + model.NewId() + "b"
o2.Email = model.NewId() + "@nowhere.com"
o2.Type = model.TEAM_OPEN
o2.AllowOpenInvite = false
Must(store.Team().Save(&o2))
o3 := model.Team{}
o3.DisplayName = "DisplayName"
o3.Name = "z-z-z" + model.NewId() + "b"
o3.Email = model.NewId() + "@nowhere.com"
o3.Type = model.TEAM_INVITE
o3.AllowOpenInvite = true
Must(store.Team().Save(&o3))
o4 := model.Team{}
o4.DisplayName = "DisplayName"
o4.Name = "zz" + model.NewId() + "b"
o4.Email = model.NewId() + "@nowhere.com"
o4.Type = model.TEAM_INVITE
o4.AllowOpenInvite = false
Must(store.Team().Save(&o4))
if r1 := <-store.Team().GetAllTeamPageListing(0, 10); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
for _, team := range teams {
if !team.AllowOpenInvite {
t.Fatal("should have returned team with AllowOpenInvite as true")
}
}
if len(teams) > 10 {
t.Fatal("should have returned max of 10 teams")
}
}
o5 := model.Team{}
o5.DisplayName = "DisplayName"
o5.Name = "z-z-z" + model.NewId() + "b"
o5.Email = model.NewId() + "@nowhere.com"
o5.Type = model.TEAM_OPEN
o5.AllowOpenInvite = true
Must(store.Team().Save(&o5))
if r1 := <-store.Team().GetAllTeamPageListing(0, 4); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
for _, team := range teams {
if !team.AllowOpenInvite {
t.Fatal("should have returned team with AllowOpenInvite as true")
}
}
if len(teams) > 4 {
t.Fatal("should have returned max of 4 teams")
}
}
if r1 := <-store.Team().GetAllTeamPageListing(1, 1); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
for _, team := range teams {
if !team.AllowOpenInvite {
t.Fatal("should have returned team with AllowOpenInvite as true")
}
}
if len(teams) > 1 {
t.Fatal("should have returned max of 1 team")
}
}
}
func TestDelete(t *testing.T) {
Setup()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment