PluginAPI: add ability to retrieve users by ids (#26936)
* pluginapi: ability to retrieve users by ids * fix test
Этот коммит содержится в:
@@ -96,6 +96,35 @@ func TestGetUsers(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestListByUserIDs(t *testing.T) {
|
||||
t.Run("success", func(t *testing.T) {
|
||||
api := &plugintest.API{}
|
||||
defer api.AssertExpectations(t)
|
||||
client := pluginapi.NewClient(api, &plugintest.Driver{})
|
||||
|
||||
userIDs := []string{"123"}
|
||||
expectedUsers := []*model.User{{Id: "123", Username: "test"}}
|
||||
api.On("GetUsersByIds", userIDs).Return(expectedUsers, nil)
|
||||
|
||||
actualUsers, err := client.User.ListByUserIDs(userIDs)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedUsers, actualUsers)
|
||||
})
|
||||
|
||||
t.Run("failure", func(t *testing.T) {
|
||||
api := &plugintest.API{}
|
||||
defer api.AssertExpectations(t)
|
||||
client := pluginapi.NewClient(api, &plugintest.Driver{})
|
||||
|
||||
userIDs := []string{"123"}
|
||||
api.On("GetUsersByIds", userIDs).Return(nil, newAppError())
|
||||
|
||||
actualUsers, err := client.User.ListByUserIDs(userIDs)
|
||||
require.EqualError(t, err, "here: id, an error occurred")
|
||||
assert.Nil(t, actualUsers)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetUser(t *testing.T) {
|
||||
t.Run("success", func(t *testing.T) {
|
||||
api := &plugintest.API{}
|
||||
|
||||
Ссылка в новой задаче
Block a user