Skip to content

Commit

Permalink
[UPDATE] updated deno stand to 0.125.0
Browse files Browse the repository at this point in the history
[CHORE] had to change all assertThrows, assertThrowsAsync with the new apis provided by deno
  • Loading branch information
aricart committed Feb 16, 2022
1 parent 4fabcfc commit e114694
Show file tree
Hide file tree
Showing 52 changed files with 218 additions and 162 deletions.
4 changes: 2 additions & 2 deletions bin/exports.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parse } from "https://deno.land/std@0.103.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import {
basename,
extname,
join,
resolve,
} from "https://deno.land/std@0.103.0/path/mod.ts";
} from "https://deno.land/std@0.125.0/path/mod.ts";

const argv = parse(
Deno.args,
Expand Down
8 changes: 4 additions & 4 deletions dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This file lists the dependencies used in this repository.

| Dependency | License |
| ----------------------------------------- | ----------- |
| https://deno.land/std@0.95.0/flags/mod.ts | MIT License |
| http://github.com/nats-io/nkeys.js | Apache-2.0 |
| Dependency | License |
| ------------------------------------------ | ----------- |
| https://deno.land/std@0.125.0/flags/mod.ts | MIT License |
| http://github.com/nats-io/nkeys.js | Apache-2.0 |
2 changes: 1 addition & 1 deletion examples/bench.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env deno run --allow-all --unstable

import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import { connect, Nuid } from "../src/mod.ts";
import { Bench, Metric } from "../nats-base-client/bench.ts";
const defaults = {
Expand Down
2 changes: 1 addition & 1 deletion examples/nats-events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env deno run --allow-all --unstable

import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import { connect, ConnectionOptions } from "../src/mod.ts";

const argv = parse(
Expand Down
2 changes: 1 addition & 1 deletion examples/nats-pub.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env deno run --allow-all --unstable

import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import {
connect,
ConnectionOptions,
Expand Down
2 changes: 1 addition & 1 deletion examples/nats-rep.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env deno run --allow-all --unstable

import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import {
connect,
ConnectionOptions,
Expand Down
2 changes: 1 addition & 1 deletion examples/nats-req.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env deno run --allow-all --unstable

import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import {
connect,
ConnectionOptions,
Expand Down
2 changes: 1 addition & 1 deletion examples/nats-sub.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env deno run --allow-all --unstable

import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.125.0/flags/mod.ts";
import {
connect,
ConnectionOptions,
Expand Down
4 changes: 2 additions & 2 deletions src/deno_transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* limitations under the License.
*/

import { BufWriter } from "https://deno.land/std@0.95.0/io/mod.ts";
import { Deferred, deferred } from "https://deno.land/std@0.95.0/async/mod.ts";
import { BufWriter } from "https://deno.land/std@0.125.0/io/mod.ts";
import { Deferred, deferred } from "https://deno.land/std@0.125.0/async/mod.ts";
import Conn = Deno.Conn;
import {
checkOptions,
Expand Down
2 changes: 1 addition & 1 deletion tests/auth_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import {
assertEquals,
fail,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";
import {
connect,
credsAuthenticator,
Expand Down
2 changes: 1 addition & 1 deletion tests/autounsub_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.125.0/testing/asserts.ts";

import { createInbox, Empty, ErrorCode, Subscription } from "../src/mod.ts";
import { Lock } from "./helpers/mod.ts";
Expand Down
23 changes: 13 additions & 10 deletions tests/basics_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
import {
assert,
assertEquals,
assertRejects,
assertThrows,
assertThrowsAsync,
fail,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";

import { assertThrowsAsyncErrorCode } from "./helpers/asserts.ts";

import {
connect,
createInbox,
Expand Down Expand Up @@ -363,21 +366,19 @@ Deno.test("basics - request", async () => {
Deno.test("basics - request no responders", async () => {
const { ns, nc } = await setup();
const s = createInbox();
const err = await assertThrowsAsync(async () => {
await assertThrowsAsyncErrorCode(async () => {
await nc.request(s, Empty, { timeout: 100 });
});
assertErrorCode(err, ErrorCode.NoResponders);
}, ErrorCode.NoResponders);
await cleanup(ns, nc);
});

Deno.test("basics - request timeout", async () => {
const { ns, nc } = await setup();
const s = createInbox();
nc.subscribe(s, { callback: () => {} });
const err = await assertThrowsAsync(async () => {
await assertThrowsAsyncErrorCode(async () => {
await nc.request(s, Empty, { timeout: 100 });
});
assertErrorCode(err, ErrorCode.Timeout);
}, ErrorCode.Timeout);
await cleanup(ns, nc);
});

Expand Down Expand Up @@ -449,13 +450,14 @@ Deno.test("basics - request with custom subject", async () => {

Deno.test("basics - request requires a subject", async () => {
const { ns, nc } = await setup();
await assertThrowsAsync(
await assertRejects(
async () => {
//@ts-ignore: subject missing on purpose
await nc.request();
},
NatsError,
"BAD_SUBJECT",
undefined,
);
await cleanup(ns, nc);
});
Expand Down Expand Up @@ -867,11 +869,12 @@ Deno.test("basics - resolve", async () => {
});

Deno.test("basics - port and server are mutually exclusive", async () => {
await assertThrowsAsync(
await assertRejects(
async () => {
await connect({ servers: "localhost", port: 4222 });
},
NatsError,
"port and servers options are mutually exclusive",
undefined,
);
});
2 changes: 1 addition & 1 deletion tests/bench_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
assert,
assertEquals,
assertThrows,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";
import { Bench, connect, createInbox } from "../src/mod.ts";
import { BenchOpts, Metric } from "../nats-base-client/bench.ts";

Expand Down
2 changes: 1 addition & 1 deletion tests/binary_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.125.0/testing/asserts.ts";
import { createInbox, Msg } from "../src/mod.ts";
import { deferred } from "../nats-base-client/internal_mod.ts";
import { cleanup, setup } from "./jstest_util.ts";
Expand Down
2 changes: 1 addition & 1 deletion tests/buffer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
assert,
assertEquals,
assertThrows,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";
import {
DenoBuffer,
MAX_SIZE,
Expand Down
2 changes: 1 addition & 1 deletion tests/clobber_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { NatsServer } from "./helpers/launcher.ts";
import { createInbox, DataBuffer } from "../nats-base-client/internal_mod.ts";
import { connect } from "../src/mod.ts";
import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.125.0/testing/asserts.ts";

function makeBuffer(N: number): Uint8Array {
const buf = new Uint8Array(N);
Expand Down
2 changes: 1 addition & 1 deletion tests/codec_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/
import { JSONCodec, StringCodec } from "../nats-base-client/codec.ts";
import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.125.0/testing/asserts.ts";

Deno.test("codec - string", () => {
const sc = StringCodec();
Expand Down
2 changes: 1 addition & 1 deletion tests/consumeropts_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
assert,
assertEquals,
assertThrows,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";

import {
consumerOpts,
Expand Down
2 changes: 1 addition & 1 deletion tests/databuffer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.125.0/testing/asserts.ts";
import { DataBuffer } from "../nats-base-client/internal_mod.ts";

Deno.test("databuffer - empty", () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/doublesubs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
import {
assertArrayIncludes,
assertEquals,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";
import { extend } from "../nats-base-client/util.ts";
import { join, resolve } from "https://deno.land/std@0.95.0/path/mod.ts";
import { join, resolve } from "https://deno.land/std@0.125.0/path/mod.ts";

async function runDoubleSubsTest(tls: boolean) {
const cwd = Deno.cwd();
Expand Down
39 changes: 19 additions & 20 deletions tests/drain_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import {
assert,
assertEquals,
assertThrows,
assertThrowsAsync,
fail,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";
import {
assertThrowsAsyncErrorCode,
} from "./helpers/asserts.ts";
import {
connect,
createInbox,
Expand Down Expand Up @@ -126,14 +128,15 @@ Deno.test("drain - publish after drain fails", async () => {
nc.subscribe(subj);
await nc.drain();

const err = assertThrows(() => {
assertThrows(() => {
nc.publish(subj);
}, (err: Error) => {
assertErrorCode(
err,
ErrorCode.ConnectionClosed,
ErrorCode.ConnectionDraining,
);
});
assertErrorCode(
err,
ErrorCode.ConnectionClosed,
ErrorCode.ConnectionDraining,
);
await ns.stop();
});

Expand Down Expand Up @@ -187,21 +190,19 @@ Deno.test("drain - reject reqrep during connection drain", async () => {
Deno.test("drain - reject drain on closed", async () => {
const { ns, nc } = await setup();
await nc.close();
const err = await assertThrowsAsync(async () => {
await assertThrowsAsyncErrorCode(async () => {
await nc.drain();
});
assertErrorCode(err, ErrorCode.ConnectionClosed);
}, ErrorCode.ConnectionClosed);
await ns.stop();
});

Deno.test("drain - reject drain on draining", async () => {
const { ns, nc } = await setup();
const done = nc.drain();
const err = await assertThrowsAsync(() => {
await assertThrowsAsyncErrorCode(() => {
return nc.drain();
});
}, ErrorCode.ConnectionDraining);
await done;
assertErrorCode(err, ErrorCode.ConnectionDraining);
await ns.stop();
});

Expand All @@ -219,11 +220,10 @@ Deno.test("drain - reject subscription drain on closed sub", async () => {
const { ns, nc } = await setup();
const sub = nc.subscribe("foo");
sub.unsubscribe();
const err = await assertThrowsAsync(() => {
await assertThrowsAsyncErrorCode(() => {
return sub.drain();
});
}, ErrorCode.SubClosed);
await nc.close();
assertErrorCode(err, ErrorCode.SubClosed);
await ns.stop();
});

Expand All @@ -239,10 +239,9 @@ Deno.test("drain - reject subscription drain on closed", async () => {
const { ns, nc } = await setup();
const sub = nc.subscribe("foo");
await nc.close();
const err = await assertThrowsAsync(() => {
await assertThrowsAsyncErrorCode(() => {
return sub.drain();
});
assertErrorCode(err, ErrorCode.ConnectionClosed);
}, ErrorCode.ConnectionClosed);
await ns.stop();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/events_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
import { Lock, NatsServer, ServerSignals } from "../tests/helpers/mod.ts";
import { connect, Events, ServersChanged } from "../src/mod.ts";
import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.125.0/testing/asserts.ts";
import { delay, NatsConnectionImpl } from "../nats-base-client/internal_mod.ts";
import { setup } from "./jstest_util.ts";

Expand Down
2 changes: 1 addition & 1 deletion tests/headers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
assert,
assertEquals,
assertThrows,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";
import {
MsgHdrsImpl,
MsgImpl,
Expand Down
2 changes: 1 addition & 1 deletion tests/heartbeats_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
assert,
assertEquals,
fail,
} from "https://deno.land/std@0.95.0/testing/asserts.ts";
} from "https://deno.land/std@0.125.0/testing/asserts.ts";

import {
DebugEvents,
Expand Down
Loading

0 comments on commit e114694

Please sign in to comment.