[MM-13750] Add ability to search teams to plugin API (#10116)

Add SearchTeams in plugin/api,
This commit is contained in:
Adzim Zul Fahmi
2019-01-16 15:13:15 +07:00
committed by Hanzei
parent ae76d27b7d
commit dfb9241e82
5 changed files with 90 additions and 0 deletions

View File

@@ -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)
})
}