diff --git a/models/user_test.go b/models/user_test.go index bcb955817c330..8be59c5d725d3 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -373,3 +373,16 @@ func TestCreateUser_Issue5882(t *testing.T) { assert.NoError(t, DeleteUser(v.user)) } } + +func TestGetUserIDsByNames(t *testing.T) { + + //ignore non existing + IDs, err := GetUserIDsByNames([]string{"user1", "user2", "do_not_exist"}, true) + assert.NoError(t, err) + assert.Equal(t, []int64{1, 2}, IDs) + + //ignore non existing + IDs, err = GetUserIDsByNames([]string{"user1", "do_not_exist"}, false) + assert.Error(t, err) + assert.Equal(t, []int64{}, IDs) +}