complement/cmd/homerunner/test/test.mjs
kegsay 51b49035f6
Add homerunner integration tests (#408)
* Add homerunner integration tests

Uses homerunner-client which also serves to make sure the client works.

* Be in the right working directory

* Again with the working directories

* Poll a non-existent endpoint to 404 rather than sleeping for an arbitrary amount of time; more robust on slow GHA boxes

* Use env vars

* Purposefully break the test to ensure things fail

* Fix test

* Update cmd/homerunner/test/test.mjs

Co-authored-by: Will Hunt <will@half-shot.uk>

Co-authored-by: Will Hunt <will@half-shot.uk>
2022-07-11 12:18:41 +01:00

36 lines
1.1 KiB
JavaScript

import { Homerunner } from "homerunner-client";
const run = async () => {
const client = new Homerunner.Client();
console.log("homerunner base url:", client.baseUrl);
console.log("creating homeserver...");
const blueprint = await client.create({
base_image_uri: "complement-dendrite",
blueprint_name: "one_to_one_room",
});
console.log("Client.create responded with", blueprint);
// verify blueprint fields
if (!blueprint.expires) {
throw new Error("missing 'expires' key in response");
}
const hs1 = blueprint.homeservers["hs1"];
if (!hs1) {
throw new Error("missing hs1 in response");
}
const wantKeys = ["BaseURL", "FedBaseURL", "ContainerID", "AccessTokens", "DeviceIDs"];
wantKeys.forEach((k) => {
if (!hs1[k]) {
throw new Error("hs1 missing key: " + k);
}
});
console.log("destroying homeserver...");
await client.destroy("one_to_one_room");
};
run().then(() => {
process.exit(0);
}).catch((err) => {
console.error("Tests failed:",err.message);
process.exit(1);
})