Skip to content

Commit

Permalink
readded userinformation error unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ARADDCC002 committed Nov 26, 2024
1 parent 2fd33d6 commit 27697e6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backend/test/services/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ describe('services > model', () => {
expect(modelMocks.save).not.toBeCalled()
})

test('createModel > should throw an internal error if getUserInformation fails due to invalid user', async () => {
authenticationMocks.getUserInformation.mockImplementation(() => {
throw new Error('Unable to find user user:unknown_user')
})
expect(() =>
createModel({} as any, { collaborators: [{ entity: 'user:unknown_user', roles: [] }] } as any),
).rejects.toThrowError(/^Unable to find user user:unknown_user/)
})

test('getModelById > good', async () => {
modelMocks.findOne.mockResolvedValueOnce('mocked')

Expand Down Expand Up @@ -327,6 +336,15 @@ describe('services > model', () => {
).rejects.toThrowError(/^You cannot select both mirror settings simultaneously./)
})

test('updateModel > should throw an internal error if getUserInformation fails due to invalid user', async () => {
authenticationMocks.getUserInformation.mockImplementation(() => {
throw new Error('Unable to find user user:unknown_user')
})
expect(() =>
updateModel({} as any, '123', { collaborators: [{ entity: 'user:unknown_user', roles: [] }] }),
).rejects.toThrowError(/^Unable to find user user:unknown_user/)
})

test('createModelcardFromSchema > should throw an error when attempting to change a model from mirrored to standard', async () => {
vi.mocked(authorisation.model).mockResolvedValue({
info: 'Cannot alter a mirrored model.',
Expand Down

0 comments on commit 27697e6

Please sign in to comment.