Skip to content

Add integration tests#34

Open
heavyrubberslave wants to merge 2 commits into
mainfrom
feat/add-integration-tests
Open

Add integration tests#34
heavyrubberslave wants to merge 2 commits into
mainfrom
feat/add-integration-tests

Conversation

@heavyrubberslave

@heavyrubberslave heavyrubberslave commented Feb 4, 2024

Copy link
Copy Markdown
Member

Maybe setTimeout and setInterval calls should be wrapped and called via a factory so it’s easy to globally control whether they should be instantiated with unref() or not.

Had to add the unref() calls because else supertest could not shut down the app process and jest was complaining. Not sure if this behavior is also ok outside of the testing context as it will stop SlvCtrl+ from functioning if express‘ event loop stops…

Alternatively the factory could maybe be made stateful, knowing of all setInterval/setTimeout and reset them gracefully on express shutdown.

Alternatively express should fire an event on shutdown and the deviceproviders should receive this event and reset all devices to a 0 state before the process exits. 0 state in the sense that all values are set to 0/neutral and all device updaters and other intervals are cleared. (Probably the cleanest approach.)

// Create an express app
const app = express();

// Start listening on port 3000
const server = app.listen(3000, () => console.log('Server running on port 3000'));

// Listen to the 'close' event
server.on('close', () => {
  console.log('Server closed');
  // Close any other resources and set connected devices to 0/neutral state, close websocket connection for buttplugIo source, etc
});

@heavyrubberslave heavyrubberslave added the enhancement New feature or request label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant