WIP: feedback

This commit is contained in:
David Teller 2022-11-15 12:51:54 +01:00
parent f1720ddb41
commit 96066ace23
2 changed files with 8 additions and 8 deletions

View File

@ -3,31 +3,30 @@ import { strict as assert } from "assert";
import { newTestUser } from "./clientHelper"; import { newTestUser } from "./clientHelper";
import { Mjolnir } from "../../src/Mjolnir"; import { Mjolnir } from "../../src/Mjolnir";
import { read as configRead } from "../../src/config"; import { read as configRead } from "../../src/config";
import { getRequestFn, LogService, MatrixClient } from "matrix-bot-sdk"; import { getRequestFn, LogService } from "matrix-bot-sdk";
import { createBanList, getFirstReaction } from "./commands/commandUtils"; import { createBanList, getFirstReaction } from "./commands/commandUtils";
/** /**
* Get a copy of the rules from the ruleserver. * Get a copy of the rules from the ruleserver.
*/ */
async function currentRules(mjolnir: Mjolnir): Promise<{ start: object, stop: object, since: string }> { async function currentRules(mjolnir: Mjolnir): Promise<{ start: object, stop: object, since: string }> {
return await new Promise((resolve, reject) => { return await new Promise((resolve, reject) => getRequestFn()({
return getRequestFn()({
uri: `http://${mjolnir.config.web.address}:${mjolnir.config.web.port}/api/1/ruleserver/updates/`, uri: `http://${mjolnir.config.web.address}:${mjolnir.config.web.port}/api/1/ruleserver/updates/`,
method: "GET" method: "GET"
}, (error, _response, body) => { }, (error: object, _response: any, body: string) => {
if (error) { if (error) {
reject(error) reject(error)
} else { } else {
resolve(JSON.parse(body)) resolve(JSON.parse(body))
} }
})}); }));
} }
/** /**
* Wait for the rules to change as a result of the thunk. The returned promise will resolve when the rules being served have changed. * Wait for the rules to change as a result of the thunk. The returned promise will resolve when the rules being served have changed.
* @param thunk Should cause the rules the RuleServer is serving to change some way. * @param thunk Should cause the rules the RuleServer is serving to change some way.
*/ */
async function waitForRuleChange(mjolnir: Mjolnir, thunk): Promise<void> { async function waitForRuleChange(mjolnir: Mjolnir, thunk: any): Promise<void> {
const initialRules = await currentRules(mjolnir); const initialRules = await currentRules(mjolnir);
let rules = initialRules; let rules = initialRules;
// We use JSON.stringify like this so that it is pretty printed in the log and human readable. // We use JSON.stringify like this so that it is pretty printed in the log and human readable.

View File

@ -23,6 +23,7 @@
"./test/integration/manualLaunchScript.ts", "./test/integration/manualLaunchScript.ts",
"./test/integration/roomMembersTest.ts", "./test/integration/roomMembersTest.ts",
"./test/integration/banListTest.ts", "./test/integration/banListTest.ts",
"./test/integration/reportPollingTest" "./test/integration/reportPollingTest",
"./test/integration/policyConsumptionTest.ts",
] ]
} }