Unit test fix
This commit is contained in:
parent
33bc8f1863
commit
bc885f4612
4 changed files with 9 additions and 13 deletions
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"deno.enable": true,
|
||||
"deno.suggest.imports.hosts": {
|
||||
"https://deno.land": false
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ export async function disableLocalStorage(
|
|||
const removed = ns["localStorage"];
|
||||
delete ns["localStorage"];
|
||||
try {
|
||||
await body;
|
||||
await body();
|
||||
} finally {
|
||||
ns["localStorage"] = removed;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue