mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Add tear down to APIv4 tests (#5250)
* Add tear down to APIv4 tests * Defer tear downs
This commit is contained in:
committed by
Harrison Healey
parent
60be5c902f
commit
365514174e
@@ -60,6 +60,34 @@ func Setup() *TestHelper {
|
||||
return th
|
||||
}
|
||||
|
||||
func TearDown() {
|
||||
options := map[string]bool{}
|
||||
options[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
if result := <-app.Srv.Store.User().Search("", "fakeuser", options); result.Err != nil {
|
||||
l4g.Error("Error tearing down test users")
|
||||
} else {
|
||||
users := result.Data.([]*model.User)
|
||||
|
||||
for _, u := range users {
|
||||
if err := app.PermanentDeleteUser(u); err != nil {
|
||||
l4g.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-app.Srv.Store.Team().SearchByName("faketeam"); result.Err != nil {
|
||||
l4g.Error("Error tearing down test teams")
|
||||
} else {
|
||||
teams := result.Data.([]*model.Team)
|
||||
|
||||
for _, t := range teams {
|
||||
if err := app.PermanentDeleteTeam(t); err != nil {
|
||||
l4g.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.TeamAdminUser = me.CreateUser()
|
||||
me.LoginTeamAdmin()
|
||||
|
||||
Reference in New Issue
Block a user