Skip to content

Commit

Permalink
Update to deno 1.17 🎉 + fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Dec 17, 2021
1 parent ccdaeba commit af20963
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deno-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: denoland/setup-deno@v1
with:
deno-version: v1.16.x
deno-version: v1.17.x

- name: Install dev deps
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: denoland/setup-deno@v1
if: steps.release.outputs.version == 0
with:
deno-version: v1.16.x
deno-version: v1.17.x

- name: Install dev deps
if: steps.release.outputs.version == 0
Expand Down
1 change: 1 addition & 0 deletions src/adapter.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
HmacSha256,
} from "https://deno.land/[email protected]/hash/sha256.ts";
import path from "https://deno.land/[email protected]/node/path.ts";
import * as _fs from "https://deno.land/[email protected]/fs/mod.ts";
import EventEmitter from "https://deno.land/[email protected]/node/events.ts";
import util from "https://deno.land/[email protected]/node/util.ts";
import {iterateReader} from "https://deno.land/[email protected]/streams/conversion.ts";
Expand Down
54 changes: 33 additions & 21 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function setStringCodecs(codecs: string[], client: Client) {
);
}

class CancelTransaction extends Error {}

test("query: basic scalars", async () => {
const con = getClient();
let res: any;
Expand Down Expand Up @@ -1219,32 +1221,38 @@ test("fetch: uuid", async () => {
test("fetch: enum", async () => {
const client = getClient();

await client.withRetryOptions({attempts: 1}).transaction(async tx => {
await tx.execute(`
try {
await client.withRetryOptions({attempts: 1}).transaction(async tx => {
await tx.execute(`
CREATE SCALAR TYPE MyEnum EXTENDING enum<"A", "B">;
`);

// await tx.query("declare savepoint s1");
// await tx
// .querySingle("SELECT <MyEnum><str>$0", ["Z"])
// .then(() => {
// throw new Error("an exception was expected");
// })
// .catch((e) => {
// expect(e.toString()).toMatch(/invalid input value for enum/);
// });
// await tx.query("rollback to savepoint s1");
// await tx.query("declare savepoint s1");
// await tx
// .querySingle("SELECT <MyEnum><str>$0", ["Z"])
// .then(() => {
// throw new Error("an exception was expected");
// })
// .catch((e) => {
// expect(e.toString()).toMatch(/invalid input value for enum/);
// });
// await tx.query("rollback to savepoint s1");

let ret = await tx.querySingle("SELECT <MyEnum><str>$0", ["A"]);
expect(ret).toBe("A");
let ret = await tx.querySingle("SELECT <MyEnum><str>$0", ["A"]);
expect(ret).toBe("A");

ret = await tx.querySingle("SELECT <MyEnum>$0", ["A"]);
expect(ret).toBe("A");
ret = await tx.querySingle("SELECT <MyEnum>$0", ["A"]);
expect(ret).toBe("A");

await tx.rollback();
});

await client.close();
throw new CancelTransaction();
});
} catch (e) {
if (!(e instanceof CancelTransaction)) {
throw e;
}
} finally {
await client.close();
}
});

test("fetch: namedtuple", async () => {
Expand Down Expand Up @@ -1572,8 +1580,12 @@ test("fetch/optimistic cache invalidation", async () => {
expect(res).toBe(123);
}

await tx.rollback();
throw new CancelTransaction();
});
} catch (e) {
if (!(e instanceof CancelTransaction)) {
throw e;
}
} finally {
await client.close();
}
Expand Down

0 comments on commit af20963

Please sign in to comment.