Skip to content

Commit

Permalink
Test Updates/Fixes (#620)
Browse files Browse the repository at this point in the history
Test updates/Fixes
  • Loading branch information
anissa-agahchen authored Oct 29, 2021
1 parent db15ba7 commit 85245b8
Show file tree
Hide file tree
Showing 66 changed files with 879 additions and 913 deletions.
3 changes: 2 additions & 1 deletion api/src/database/db.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe } from 'mocha';
import * as pg from 'pg';
import Sinon from 'sinon';
import { SYSTEM_IDENTITY_SOURCE } from '../constants/database';
import { CustomError } from '../errors/CustomError';
import { setSystemUserContextSQL } from '../queries/user-context-queries';
import * as db from './db';
import { getAPIUserDBConnection, getDBConnection, getDBPool, IDBConnection, initDBPool } from './db';
Expand Down Expand Up @@ -36,7 +37,7 @@ describe('db', () => {

expect.fail();
} catch (actualError) {
expect(actualError.message).to.equal('Keycloak token is undefined');
expect((actualError as CustomError).message).to.equal('Keycloak token is undefined');
}
});

Expand Down
29 changes: 15 additions & 14 deletions api/src/paths/access-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as user_queries from '../queries/users/user-queries';
import * as db from '../database/db';
import SQL from 'sql-template-strings';
import { getMockDBConnection } from '../__mocks__/db';
import { CustomError } from '../errors/CustomError';

chai.use(sinonChai);

Expand Down Expand Up @@ -38,8 +39,8 @@ describe('updateAccessRequest', () => {
);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required body param: userIdentifier');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required body param: userIdentifier');
}
});

Expand All @@ -54,8 +55,8 @@ describe('updateAccessRequest', () => {
);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required body param: identitySource');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required body param: identitySource');
}
});

Expand All @@ -70,8 +71,8 @@ describe('updateAccessRequest', () => {
);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required body param: requestId');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required body param: requestId');
}
});

Expand All @@ -86,8 +87,8 @@ describe('updateAccessRequest', () => {
);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required body param: requestStatusTypeId');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required body param: requestStatusTypeId');
}
});

Expand All @@ -106,8 +107,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Failed to build SQL get statement');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Failed to build SQL get statement');
}
});

Expand All @@ -134,8 +135,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Failed to identify system user ID');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Failed to identify system user ID');
}
});

Expand Down Expand Up @@ -169,8 +170,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to get or add system user');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to get or add system user');
}
});
});
5 changes: 3 additions & 2 deletions api/src/paths/administrative-activities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as administrative_queries from '../queries/administrative-activity/admi
import * as db from '../database/db';
import { getMockDBConnection } from '../__mocks__/db';
import SQL from 'sql-template-strings';
import { CustomError } from '../errors/CustomError';

chai.use(sinonChai);

Expand Down Expand Up @@ -47,8 +48,8 @@ describe('getAdministrativeActivities', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Failed to build SQL get statement');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Failed to build SQL get statement');
}
});

Expand Down
41 changes: 21 additions & 20 deletions api/src/paths/administrative-activity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as db from '../database/db';
import { getMockDBConnection } from '../__mocks__/db';
import SQL from 'sql-template-strings';
import * as keycloak_utils from '../utils/keycloak-utils';
import { CustomError } from '../errors/CustomError';

chai.use(sinonChai);

Expand Down Expand Up @@ -48,8 +49,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to identify system user ID');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to identify system user ID');
}
});

Expand All @@ -68,8 +69,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to build SQL insert statement');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to build SQL insert statement');
}
});

Expand All @@ -95,8 +96,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to submit administrative activity');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to submit administrative activity');
}
});

Expand Down Expand Up @@ -127,8 +128,8 @@ describe('updateAccessRequest', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to submit administrative activity');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to submit administrative activity');
}
});

Expand Down Expand Up @@ -196,8 +197,8 @@ describe('getPendingAccessRequestsCount', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required userIdentifier');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required userIdentifier');
}
});

Expand All @@ -217,8 +218,8 @@ describe('getPendingAccessRequestsCount', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Failed to build SQL get statement');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Failed to build SQL get statement');
}
});

Expand Down Expand Up @@ -293,8 +294,8 @@ describe('getUpdateAdministrativeActivityHandler', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required body parameter: id');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required body parameter: id');
}
});

Expand All @@ -309,8 +310,8 @@ describe('getUpdateAdministrativeActivityHandler', () => {
);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Missing required body parameter: status');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Missing required body parameter: status');
}
});
});
Expand All @@ -335,8 +336,8 @@ describe('updateAdministrativeActivity', () => {

expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(400);
expect(actualError.message).to.equal('Failed to build SQL put statement');
expect((actualError as CustomError).status).to.equal(400);
expect((actualError as CustomError).message).to.equal('Failed to build SQL put statement');
}
});

Expand All @@ -360,8 +361,8 @@ describe('updateAdministrativeActivity', () => {

expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to update administrative activity');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to update administrative activity');
}
});
});
7 changes: 4 additions & 3 deletions api/src/paths/codes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as codes from './codes';
import * as db from '../database/db';
import * as code_utils from '../utils/code-utils';
import { getMockDBConnection } from '../__mocks__/db';
import { CustomError } from '../errors/CustomError';

chai.use(sinonChai);

Expand Down Expand Up @@ -45,8 +46,8 @@ describe('codes', () => {
await result(sampleReq, (null as unknown) as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.status).to.equal(500);
expect(actualError.message).to.equal('Failed to fetch codes');
expect((actualError as CustomError).status).to.equal(500);
expect((actualError as CustomError).message).to.equal('Failed to fetch codes');
}
});

Expand Down Expand Up @@ -75,7 +76,7 @@ describe('codes', () => {
await result(sampleReq, sampleRes as any, (null as unknown) as any);
expect.fail();
} catch (actualError) {
expect(actualError.message).to.equal(expectedError.message);
expect((actualError as CustomError).message).to.equal(expectedError.message);
}
});
});
Expand Down
Loading

0 comments on commit 85245b8

Please sign in to comment.