[MM-13750] Add ability to search teams to plugin API (#10116)
Add SearchTeams in plugin/api,
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
ae76d27b7d
Коммит
dfb9241e82
@@ -118,6 +118,10 @@ func (api *PluginAPI) GetTeam(teamId string) (*model.Team, *model.AppError) {
|
||||
return api.app.GetTeam(teamId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchTeams(term string) ([]*model.Team, *model.AppError) {
|
||||
return api.app.SearchAllTeams(term)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetTeamByName(name string) (*model.Team, *model.AppError) {
|
||||
return api.app.GetTeamByName(name)
|
||||
}
|
||||
|
||||
@@ -721,3 +721,30 @@ func TestPluginAPISendMail(t *testing.T) {
|
||||
require.Equal(t, resultsEmail.Body.Text, body)
|
||||
|
||||
}
|
||||
|
||||
func TestPluginAPI_SearchTeams(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
t.Run("all fine", func(t *testing.T) {
|
||||
teams, err := api.SearchTeams(th.BasicTeam.Name)
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, teams, 1)
|
||||
|
||||
teams, err = api.SearchTeams(th.BasicTeam.DisplayName)
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, teams, 1)
|
||||
|
||||
teams, err = api.SearchTeams(th.BasicTeam.Name[:3])
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, teams, 1)
|
||||
})
|
||||
|
||||
t.Run("invalid team name", func(t *testing.T) {
|
||||
teams, err := api.SearchTeams("not found")
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, teams)
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user