Skip to content

Commit 38b18cd

Browse files
authored
Appservice tests weren't added to tsconfig.json properly. (#440)
Some minor fixes now that they have been.
1 parent f52f17e commit 38b18cd

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

src/appservice/AppService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ export class MjolnirAppService {
8888
* @param config The parsed configuration file.
8989
* @param registrationFilePath A path to their homeserver registration file.
9090
*/
91-
public static async run(port: number, config: IConfig, registrationFilePath: string) {
91+
public static async run(port: number, config: IConfig, registrationFilePath: string): Promise<MjolnirAppService> {
9292
const dataStore = new PgDataStore(config.db.connectionString);
9393
await dataStore.init();
9494
const service = await MjolnirAppService.makeMjolnirAppService(config, dataStore, registrationFilePath);
9595
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
9696
await service.start(port);
97+
return service;
9798
}
9899

99100
public onUserQuery (queriedUser: MatrixUser) {

test/appservice/integration/provisionTest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe("Test that the app service can provision a mjolnir on invite of the app
1616
return this.appservice.close();
1717
} else {
1818
console.warn("Missing Appservice in this context, so cannot stop it.")
19+
return Promise.resolve(); // TS7030: Not all code paths return a value.
1920
}
2021
});
2122
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {

test/appservice/integration/webAPITest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe("Test that the app service can provision a mjolnir when requested from
2020
return this.appservice.close();
2121
} else {
2222
console.warn("Missing Appservice in this context, so cannot stop it.")
23+
return Promise.resolve(); // TS7030: Not all code paths return a value.
2324
}
2425
});
2526
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {

test/appservice/utils/harness.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import path from "path";
22
import { MjolnirAppService } from "../../../src/appservice/AppService";
33
import { ensureAliasedRoomExists } from "../../integration/mjolnirSetupUtils";
44
import { read as configRead, IConfig } from "../../../src/appservice/config/config";
5-
import { PgDataStore } from "../../../src/appservice/datastore";
65
import { newTestUser } from "../../integration/clientHelper";
76
import PolicyList from "../../../src/models/PolicyList";
87
import { CreateEvent, MatrixClient } from "matrix-bot-sdk";
@@ -15,11 +14,7 @@ export async function setupHarness(): Promise<MjolnirAppService> {
1514
const config = readTestConfig();
1615
const utilityUser = await newTestUser(config.homeserver.url, { name: { contains: "utility" }});
1716
await ensureAliasedRoomExists(utilityUser, config.accessControlList);
18-
const dataStore = new PgDataStore(config.db.connectionString);
19-
await dataStore.init();
20-
const appservice = await MjolnirAppService.makeMjolnirAppService(config, dataStore, "mjolnir-registration.yaml");
21-
await appservice.start(9000);
22-
return appservice;
17+
return await MjolnirAppService.run(9000, config, "mjolnir-registration.yaml");
2318
}
2419

2520
export async function isPolicyRoom(user: MatrixClient, roomId: string): Promise<boolean> {

test/appservice/utils/webAPIClient.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export interface CreateMjolnirResponse {
2121
export class MjolnirWebAPIClient {
2222

2323
private constructor(
24-
private readonly matrixClient: MatrixClient,
2524
private readonly openIDToken: string,
2625
private readonly baseURL: string,
2726
) {
@@ -30,7 +29,7 @@ export class MjolnirWebAPIClient {
3029

3130
public static async makeClient(client: MatrixClient, baseUrl: string): Promise<MjolnirWebAPIClient> {
3231
const token = await getOpenIDToken(client);
33-
return new MjolnirWebAPIClient(client, token, baseUrl);
32+
return new MjolnirWebAPIClient(token, baseUrl);
3433
}
3534

3635
public async createMjolnir(roomToProtectId: string): Promise<CreateMjolnirResponse> {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"include": [
2323
"./src/**/*",
24-
"./test/appservice/*",
24+
"./test/appservice/**/*",
2525
"./test/integration/manualLaunchScript.ts",
2626
"./test/integration/roomMembersTest.ts",
2727
"./test/integration/banListTest.ts",

0 commit comments

Comments
 (0)