Skip to content

Commit 1d19db5

Browse files
REALLY bad server testing
1 parent 9e6a465 commit 1d19db5

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"start:cdn": "node dist/cdn/start.js",
1111
"start:gateway": "node dist/gateway/start.js",
1212
"build": "tsc -p .",
13+
"test": "node scripts/test.js",
1314
"lint": "eslint .",
1415
"setup": "npm run build && npm run generate:schema",
1516
"sync:db": "npm run build && node scripts/syncronise.js",

scripts/test.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
3+
Copyright (C) 2023 Spacebar and Spacebar Contributors
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU Affero General Public License as published
7+
by the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU Affero General Public License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
/*
20+
Super simple script to check if the server starts at all, for use in gh actions.
21+
Not a proper test framework by any means.
22+
*/
23+
24+
const { spawn } = require("child_process");
25+
const path = require("path");
26+
27+
const server = spawn("node", [
28+
path.join(__dirname, "..", "dist", "bundle", "start.js"),
29+
]);
30+
31+
server.stdout.on("data", (data) => {
32+
process.stdout.write(data);
33+
34+
if (data.toString().toLowerCase().includes("listening")) {
35+
// we good :)
36+
console.log("we good");
37+
process.exit();
38+
}
39+
});
40+
41+
server.stderr.on("data", (err) => {
42+
process.stdout.write(err);
43+
// we bad :(
44+
process.kill(1);
45+
});
46+
47+
server.on("close", (code) => {
48+
console.log("closed with code", code);
49+
process.exit(code);
50+
});

0 commit comments

Comments
 (0)