Skip to content

Commit caa5b4b

Browse files
Add simple tests to GroundController (#297)
* Add comprehensive test suite for GroundController with mocked dependencies Co-authored-by: overtorment <overtorment@gmail.com> * Refactor code formatting and remove unnecessary whitespace Co-authored-by: overtorment <overtorment@gmail.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 20abfa2 commit caa5b4b

3 files changed

Lines changed: 614 additions & 144 deletions

File tree

src/controller/GroundController.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,29 @@ const purgeIgnoredAddressesSubscriptions = () => {
142142

143143
const killSleepingMySQLProcesses = () => {
144144
console.log("Checking for sleeping MySQL processes...");
145-
145+
146146
// Query to find processes sleeping for more than 3600 seconds
147147
const query = `
148148
SELECT id, user, host, db, command, time, state, info
149149
FROM information_schema.processlist
150150
WHERE command = 'Sleep' AND time > 3600 AND id != CONNECTION_ID()
151151
`;
152-
153-
connection.query(query)
152+
153+
connection
154+
.query(query)
154155
.then((sleepingProcesses: any[]) => {
155156
if (sleepingProcesses.length > 0) {
156157
console.log(`Found ${sleepingProcesses.length} sleeping processes older than 1 hour`);
157-
158+
158159
// Kill each sleeping process
159160
const killPromises = sleepingProcesses.map((process) => {
160161
console.log(`Killing process ID ${process.id} (user: ${process.user}, host: ${process.host}, sleeping for ${process.time}s)`);
161-
return connection.query(`KILL ${process.id}`)
162+
return connection
163+
.query(`KILL ${process.id}`)
162164
.then(() => console.log(`Successfully killed process ${process.id}`))
163165
.catch((error) => console.log(`Error killing process ${process.id}:`, error.message));
164166
});
165-
167+
166168
return Promise.all(killPromises);
167169
} else {
168170
console.log("No sleeping processes found that are older than 1 hour");

0 commit comments

Comments
 (0)