Unit test fix

This commit is contained in:
Michaël Lemaire 2021-06-22 22:07:26 +02:00
parent 33bc8f1863
commit bc885f4612
4 changed files with 9 additions and 13 deletions

View file

@ -1,7 +0,0 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"deno.enable": true,
"deno.suggest.imports.hosts": {
"https://deno.land": false
}
}

View file

@ -49,10 +49,14 @@ export class RestRemoteStorage implements KeyValueStorage {
[HEADER_REQUESTER]: this.appname,
},
});
// the body is consumed here to not leak resource, but it would
// be better to consume it only when needed, once
// https://github.com/denoland/deno/issues/4735 is fixed
const text = await response.text();
if (response.headers.get(HEADER_REPLYIER) != "ok") {
throw new Error("storage not compatible with tk-storage");
} else if (response.status == 200) {
return await response.text();
return text;
} else if (response.status == 404) {
return null;
} else {

View file

@ -56,10 +56,9 @@ export function startRestServer(
return new Promise((resolve) => {
const server = app.listen(port, () => {
resolve({
close: () =>
new Promise((resolve, reject) => {
server.close();
}),
close: async () => {
server.close();
},
});
});
});

View file

@ -31,7 +31,7 @@ export async function disableLocalStorage(
const removed = ns["localStorage"];
delete ns["localStorage"];
try {
await body;
await body();
} finally {
ns["localStorage"] = removed;
}