-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add telemetry for RBAC (no-changelog) (#8056)
- Loading branch information
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createAdmin, createMember, createOwner } from './shared/db/users'; | ||
import * as testDb from './shared/testDb'; | ||
import { RoleRepository } from '@/databases/repositories/role.repository'; | ||
import Container from 'typedi'; | ||
|
||
describe('RoleRepository', () => { | ||
let roleRepository: RoleRepository; | ||
|
||
beforeAll(async () => { | ||
await testDb.init(); | ||
|
||
roleRepository = Container.get(RoleRepository); | ||
|
||
await testDb.truncate(['User']); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testDb.terminate(); | ||
}); | ||
|
||
describe('countUsersByRole()', () => { | ||
test('should return the number of users in each role', async () => { | ||
await Promise.all([ | ||
createOwner(), | ||
createAdmin(), | ||
createAdmin(), | ||
createMember(), | ||
createMember(), | ||
createMember(), | ||
]); | ||
|
||
const usersByRole = await roleRepository.countUsersByRole(); | ||
|
||
expect(usersByRole).toStrictEqual({ admin: 2, member: 3, owner: 1 }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters