groups: remove unused addMember

This commit is contained in:
Girish Ramakrishnan
2024-01-19 17:25:36 +01:00
parent 06ce351d82
commit a8d37b917a
2 changed files with 0 additions and 36 deletions
-12
View File
@@ -11,7 +11,6 @@ exports = module.exports = {
listWithMembers,
getMembers,
addMember,
setMembers,
removeMember,
isMember,
@@ -169,17 +168,6 @@ async function setMembership(userId, groupIds) {
if (error) throw error;
}
async function addMember(groupId, userId) {
assert.strictEqual(typeof groupId, 'string');
assert.strictEqual(typeof userId, 'string');
const [error] = await safe(database.query('INSERT INTO groupMembers (groupId, userId) VALUES (?, ?)', [ groupId, userId ]));
if (error && error.code === 'ER_DUP_ENTRY') throw new BoxError(BoxError.ALREADY_EXISTS, error);
if (error && error.code === 'ER_NO_REFERENCED_ROW_2' && error.sqlMessage.includes('userId')) throw new BoxError(BoxError.NOT_FOUND, 'User not found');
if (error && error.code === 'ER_NO_REFERENCED_ROW_2') throw new BoxError(BoxError.NOT_FOUND, 'Group not found');
if (error) throw error;
}
async function setMembers(groupId, userIds) {
assert.strictEqual(typeof groupId, 'string');
assert(Array.isArray(userIds));
-24
View File
@@ -88,30 +88,6 @@ describe('Groups', function () {
expect(isMember).to.be(false);
});
it('can add member to the group', async function () {
await groups.addMember(group0Object.id, admin.id);
});
it('cannot add same member to the group', async function () {
const [error] = await safe(groups.addMember(group0Object.id, admin.id));
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
});
it('isMember returns true', async function () {
const isMember = await groups.isMember(group0Object.id, admin.id);
expect(isMember).to.be(true);
});
it('cannot add invalid user to group', async function () {
const [error] = await safe(groups.addMember(group0Object.id, 'random'));
expect(error.reason).to.be(BoxError.NOT_FOUND);
});
it('cannot add non-existent group', async function () {
const [error] = await safe(groups.addMember('randomgroup', admin.id));
expect(error.reason).to.be(BoxError.NOT_FOUND);
});
it('can set members', async function () {
await groups.setMembers(group0Object.id, [ admin.id, user.id ]);
});