Compare commits

...

5 commits

Author SHA1 Message Date
Max Leiter 4babd17383
Merge pull request #4715 from progval/test-server-teardown
tests/server: Tear down test fixtures in the order they were setup
2023-03-20 13:54:06 -07:00
Max Leiter b408843ff1
Merge pull request #4717 from thelounge/changelog
Inline logger into changelog script
2023-03-20 13:53:41 -07:00
Reto Brunner 0f3487c533 Inline logger into changelog script
We can't really import easily from our build without it being
brittle. TL isn't meant to be used as a library.

Instead, just inline the logger as it is trivial enough.
2023-03-19 23:49:42 +01:00
Val Lorentz edc6f77c64
add setup 2023-03-18 07:50:35 +01:00
Val Lorentz 0dd74a93bf tests/server: Tear down test fixtures in the order they were setup
if for whatever reason before() fails to import the server, it causes after()
to fail on the first line, so it doesn't restore stubs; causing other errors
to be printed in other tests ("TypeError: Attempted to wrap warn which is
already wrapped")
2023-03-17 17:12:29 +01:00
2 changed files with 29 additions and 2 deletions

View file

@ -53,13 +53,38 @@ const got = require("got");
const dayjs = require("dayjs");
const semver = require("semver");
const util = require("util");
const log = require("../server/log");
const packageJson = require("../package.json");
let token = process.env.CHANGELOG_TOKEN;
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
function timestamp() {
const datetime = new Date().toISOString().split(".")[0].replace("T", " ");
return colors.dim(datetime);
}
const log = {
/* eslint-disable no-console */
error(...args) {
console.error(timestamp(), colors.red("[ERROR]"), ...args);
},
warn(...args) {
console.error(timestamp(), colors.yellow("[WARN]"), ...args);
},
info(...args) {
console.log(timestamp(), colors.blue("[INFO]"), ...args);
},
debug(...args) {
console.log(timestamp(), colors.green("[DEBUG]"), ...args);
},
raw(...args) {
console.log(...args);
},
/* eslint-enable no-console */
};
const changelogPath = path.resolve(__dirname, "..", "CHANGELOG.md");
// CLI argument validations

View file

@ -39,10 +39,12 @@ describe("Server", function () {
});
after(function (done) {
server.close(done);
// Tear down test fixtures in the order they were setup,
// in case setup crashed for any reason
logInfoStub.restore();
logWarnStub.restore();
checkForUpdatesStub.restore();
server.close(done);
});
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions