Skip to content

Commit

Permalink
fix(test): update test imports
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Feb 2, 2024
1 parent 954de25 commit 04e1872
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
25 changes: 12 additions & 13 deletions tests/connection_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
assertEquals,
assertRejects,
copyStream,
deferred,
joinPath,
} from "./test_deps.ts";
import {
Expand Down Expand Up @@ -374,15 +373,15 @@ Deno.test("Closes connection on bad TLS availability verification", async functi
);

// Await for server initialization
const initialized = deferred();
const initialized = Promise.withResolvers();
server.onmessage = ({ data }) => {
if (data !== "initialized") {
initialized.reject(`Unexpected message "${data}" received from worker`);
}
initialized.resolve();
initialized.resolve(null);
};
server.postMessage("initialize");
await initialized;
await initialized.promise;

const client = new Client({
database: "none",
Expand Down Expand Up @@ -413,17 +412,17 @@ Deno.test("Closes connection on bad TLS availability verification", async functi
await client.end();
}

const closed = deferred();
const closed = Promise.withResolvers();
server.onmessage = ({ data }) => {
if (data !== "closed") {
closed.reject(
`Unexpected message "${data}" received from worker`,
);
}
closed.resolve();
closed.resolve(null);
};
server.postMessage("close");
await closed;
await closed.promise;
server.terminate();

assertEquals(bad_tls_availability_message, true);
Expand All @@ -438,15 +437,15 @@ async function mockReconnection(attempts: number) {
);

// Await for server initialization
const initialized = deferred();
const initialized = Promise.withResolvers();
server.onmessage = ({ data }) => {
if (data !== "initialized") {
initialized.reject(`Unexpected message "${data}" received from worker`);
}
initialized.resolve();
initialized.resolve(null);
};
server.postMessage("initialize");
await initialized;
await initialized.promise;

const client = new Client({
connection: {
Expand Down Expand Up @@ -483,17 +482,17 @@ async function mockReconnection(attempts: number) {
await client.end();
}

const closed = deferred();
const closed = Promise.withResolvers();
server.onmessage = ({ data }) => {
if (data !== "closed") {
closed.reject(
`Unexpected message "${data}" received from worker`,
);
}
closed.resolve();
closed.resolve(null);
};
server.postMessage("close");
await closed;
await closed.promise;
server.terminate();

// If reconnections are set to zero, it will attempt to connect at least once, but won't
Expand Down
6 changes: 3 additions & 3 deletions tests/data_types_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function generateRandomPoint(max_value = 100): Point {

const CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
function randomBase64(): string {
return base64.encode(
return base64.encodeBase64(
Array.from(
{ length: Math.ceil(Math.random() * 256) },
() => CHARS[Math.floor(Math.random() * CHARS.length)],
Expand Down Expand Up @@ -671,7 +671,7 @@ Deno.test(
`SELECT decode('${base64_string}','base64')`,
);

assertEquals(result.rows[0][0], base64.decode(base64_string));
assertEquals(result.rows[0][0], base64.decodeBase64(base64_string));
}),
);

Expand All @@ -691,7 +691,7 @@ Deno.test(

assertEquals(
result.rows[0][0],
strings.map(base64.decode),
strings.map(base64.decodeBase64),
);
}),
);
Expand Down

0 comments on commit 04e1872

Please sign in to comment.