Skip to content

Commit 27697e6

Browse files
committed
readded userinformation error unit tests
1 parent 2fd33d6 commit 27697e6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: backend/test/services/model.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ describe('services > model', () => {
120120
expect(modelMocks.save).not.toBeCalled()
121121
})
122122

123+
test('createModel > should throw an internal error if getUserInformation fails due to invalid user', async () => {
124+
authenticationMocks.getUserInformation.mockImplementation(() => {
125+
throw new Error('Unable to find user user:unknown_user')
126+
})
127+
expect(() =>
128+
createModel({} as any, { collaborators: [{ entity: 'user:unknown_user', roles: [] }] } as any),
129+
).rejects.toThrowError(/^Unable to find user user:unknown_user/)
130+
})
131+
123132
test('getModelById > good', async () => {
124133
modelMocks.findOne.mockResolvedValueOnce('mocked')
125134

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

339+
test('updateModel > should throw an internal error if getUserInformation fails due to invalid user', async () => {
340+
authenticationMocks.getUserInformation.mockImplementation(() => {
341+
throw new Error('Unable to find user user:unknown_user')
342+
})
343+
expect(() =>
344+
updateModel({} as any, '123', { collaborators: [{ entity: 'user:unknown_user', roles: [] }] }),
345+
).rejects.toThrowError(/^Unable to find user user:unknown_user/)
346+
})
347+
330348
test('createModelcardFromSchema > should throw an error when attempting to change a model from mirrored to standard', async () => {
331349
vi.mocked(authorisation.model).mockResolvedValue({
332350
info: 'Cannot alter a mirrored model.',

0 commit comments

Comments
 (0)