Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienTainon committed Dec 1, 2023
1 parent a622cae commit edc2ba8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
TEST_MODE_PLATFORM_NAME: codecast-test
TEST_MODE_USER_ID: 1
GRADER_QUEUE_DEBUG_PASSWORD: test
CODECAST_DEBUGGERS_URL: ws://127.0.0.1:9997/remote-execution
CODECAST_DEBUGGERS_URL: ws://127.0.0.1:9003
steps:
- checkout
- node/install-packages:
Expand Down
9 changes: 9 additions & 0 deletions features/steps/server_steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ interface WebSocketData {
const openServers: {[key: string]: WebSocketData} = {};
const activeConnections: {[serverName: string]: ws.WebSocket} = {};

export function closeOpenServers(): void {
for (const server of Object.values(openServers)) {
server.wss.close();
}
for (const activeConnection of Object.values(activeConnections)) {
activeConnection.close();
}
}

When(/^I connect to the "([^"]*)" WS server$/, async function (this: ServerStepsContext, serverName: string) {
const newWebSocket = new ws.WebSocket(`ws://127.0.0.1:${openServers[serverName].port}`);

Expand Down
2 changes: 2 additions & 0 deletions features/support/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {init} from '../../src/server';
import chai from 'chai';
import chaiSubset from 'chai-subset';
import {setRandomIdGenerator} from '../../src/util';
import {closeOpenServers} from '../steps/server_steps';
chai.use(chaiSubset);

let testServer: Server;
Expand Down Expand Up @@ -51,6 +52,7 @@ Before(async function () {
AfterAll(async function () {
await testServer.stop({timeout: 0});
await Db.closePool();
closeOpenServers();
});

async function cleanDatabase(): Promise<void> {
Expand Down

0 comments on commit edc2ba8

Please sign in to comment.