Skip to content

Commit

Permalink
reorg tests
Browse files Browse the repository at this point in the history
jsr changes
  • Loading branch information
aricart committed May 10, 2024
1 parent ff2359c commit ce18121
Show file tree
Hide file tree
Showing 57 changed files with 254 additions and 335 deletions.
4 changes: 2 additions & 2 deletions src/connect.ts
Expand Up @@ -18,12 +18,12 @@ import type {
NatsConnection,
Transport,
TransportFactory,
} from "@nats-io/nats-core/internal";
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

import {
NatsConnectionImpl,
setTransportFactory,
} from "@nats-io/nats-core/internal";
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

export function connect(opts: ConnectionOptions = {}): Promise<NatsConnection> {
setTransportFactory({
Expand Down
10 changes: 5 additions & 5 deletions src/deno.json
@@ -1,17 +1,17 @@
{
"name": "@nats-io/nats-transport-deno",
"version": "3.0.0-2",
"version": "3.0.0-3",
"exports": {
".": "./mod.ts"
},
"publish": {
"include": [
"./**/*"
"./*"
]
},
"imports": {
"@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@3.0.0-1/internal",
"@nats-io/nats-core": "jsr:@nats-io/nats-core@3.0.0-1",
"@std/io": "jsr:@std/io@0.224.0"
"jsr:@std/io": "jsr:@std/io@0.224.0",
"jsr:@nats-io/nats-core": "jsr:@nats-io/nats-core@3.0.0-2",
"jsr:@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@3.0.0-2/internal"
}
}
6 changes: 3 additions & 3 deletions src/deno_transport.ts
Expand Up @@ -24,17 +24,17 @@ import {
INFO,
NatsError,
render,
} from "@nats-io/nats-core/internal";
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

import type {
ConnectionOptions,
Deferred,
ServerInfo,
TlsOptions,
Transport,
} from "@nats-io/nats-core/internal";
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

import { writeAll } from "@std/io";
import { writeAll } from "jsr:@std/io";

const VERSION = "1.25.0";
const LANG = "nats.deno";
Expand Down
2 changes: 1 addition & 1 deletion src/mod.ts
@@ -1,2 +1,2 @@
export { connect } from "./connect.ts";
export * from "@nats-io/nats-core";
export * from "jsr:@nats-io/nats-core@3.0.0-11";
37 changes: 20 additions & 17 deletions tests/auth_test.ts → src/tests/auth_test.ts
Expand Up @@ -14,44 +14,47 @@
*/

import {
assert,
assertArrayIncludes,
assertEquals,
assertRejects,
fail,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
} from "jsr:@std/assert";
import { connect } from "../mod.ts";
import {
connect,
createInbox,
credsAuthenticator,
deferred,
Empty,
ErrorCode,
Events,
jwtAuthenticator,
NatsConnection,
NatsError,
NKeyAuth,
nkeyAuthenticator,
Status,
nkeys,
StringCodec,
tokenAuthenticator,
usernamePasswordAuthenticator,
} from "../mod.ts";
import type {
NatsConnection,
NatsError,
NKeyAuth,
Status,
UserPass,
} from "../src/mod.ts";
} from "../mod.ts";
import { assertErrorCode, cleanup, NatsServer, setup } from "./helpers/mod.ts";
import {
deferred,
MsgImpl,
NatsConnectionImpl,
nkeys,
} from "../nats-base-client/internal_mod.ts";
import { assert } from "../nats-base-client/denobuffer.ts";
import {
encodeAccount,
encodeOperator,
encodeUser,
} from "https://raw.githubusercontent.com/nats-io/jwt.js/main/src/jwt.ts";

import { DEFAULT_MAX_RECONNECT_ATTEMPTS } from "../nats-base-client/options.ts";
} from "jsr:@nats-io/jwt@0.0.9-3";
import type {
MsgImpl,
NatsConnectionImpl,
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import {
DEFAULT_MAX_RECONNECT_ATTEMPTS,
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

const conf = {
authorization: {
Expand Down
22 changes: 12 additions & 10 deletions tests/authenticator_test.ts → src/tests/authenticator_test.ts
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 The NATS Authors
* Copyright 2022-2024 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -15,28 +15,30 @@

import { cleanup, setup } from "./helpers/mod.ts";
import {
Auth,
Authenticator,
credsAuthenticator,
deferred,
Events,
jwtAuthenticator,
NatsConnection,
nkeyAuthenticator,
nkeys,
tokenAuthenticator,
usernamePasswordAuthenticator,
} from "../nats-base-client/mod.ts";
import { assertEquals } from "https://deno.land/std@0.221.0/assert/mod.ts";
import { nkeys } from "../nats-base-client/nkeys.ts";
} from "../mod.ts";
import type { Auth, Authenticator, NatsConnection } from "../mod.ts";

import { deadline, delay } from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import type {
NatsConnectionImpl,
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

import { assertEquals } from "jsr:@std/assert";
import {
encodeAccount,
encodeOperator,
encodeUser,
fmtCreds,
} from "https://raw.githubusercontent.com/nats-io/jwt.js/main/src/jwt.ts";
} from "jsr:@nats-io/jwt@0.0.9-3";
import { assertBetween } from "./helpers/mod.ts";
import { deadline, delay } from "../nats-base-client/util.ts";
import { NatsConnectionImpl } from "../nats-base-client/nats.ts";

function disconnectReconnect(nc: NatsConnection): Promise<void> {
const done = deferred<void>();
Expand Down
8 changes: 4 additions & 4 deletions tests/autounsub_test.ts → src/tests/autounsub_test.ts
Expand Up @@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { assertEquals } from "https://deno.land/std@0.221.0/assert/mod.ts";
import { assert, assertEquals } from "jsr:@std/assert";

import { createInbox, Empty, ErrorCode, Subscription } from "../src/mod.ts";
import { createInbox, Empty, ErrorCode } from "../mod.ts";
import type { Subscription } from "../mod.ts";
import type { NatsConnectionImpl } from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import { cleanup, Lock, setup } from "./helpers/mod.ts";
import type { NatsConnectionImpl } from "../nats-base-client/nats.ts";
import { assert } from "../nats-base-client/denobuffer.ts";

Deno.test("autounsub - max option", async () => {
const { ns, nc } = await setup();
Expand Down
33 changes: 15 additions & 18 deletions tests/basics_test.ts → src/tests/basics_test.ts
Expand Up @@ -20,22 +20,27 @@ import {
assertRejects,
assertThrows,
fail,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
} from "jsr:@std/assert";

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

import {
connect,
createInbox,
deferred,
delay,
Empty,
ErrorCode,
headers,
JSONCodec,
jwtAuthenticator,
Msg,
NatsError,
nuid,
RequestStrategy,
StringCodec,
} from "../src/mod.ts";
syncIterator,
} from "../mod.ts";
import type { Msg, Payload, PublishOptions } from "../mod.ts";
import {
assertErrorCode,
cleanup,
Expand All @@ -44,24 +49,16 @@ import {
NatsServer,
setup,
} from "./helpers/mod.ts";
import {
collect,
deferred,
delay,
headers,
isIP,
import type { MsgHdrs, Publisher } from "../mod.ts";
import type {
NatsConnectionImpl,
Payload,
PublishOptions,
RequestStrategy,
SubscriptionImpl,
} from "../nats-base-client/internal_mod.ts";
import { Feature } from "../nats-base-client/semver.ts";
import { syncIterator } from "../nats-base-client/core.ts";
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import {
MsgHdrs,
Publisher,
} from "https://deno.land/x/nats@v1.18.0/nats-base-client/core.ts";
collect,
Feature,
isIP,
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

Deno.test("basics - connect port", async () => {
const ns = await NatsServer.start();
Expand Down
10 changes: 3 additions & 7 deletions tests/bench_test.ts → src/tests/bench_test.ts
Expand Up @@ -12,13 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
assert,
assertEquals,
assertThrows,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { Bench, connect, createInbox } from "../src/mod.ts";
import { BenchOpts, Metric } from "../nats-base-client/bench.ts";
import { assert, assertEquals, assertThrows } from "jsr:@std/assert";
import { Bench, connect, createInbox, Metric } from "../mod.ts";
import type { BenchOpts } from "../mod.ts";

const u = "demo.nats.io:4222";

Expand Down
6 changes: 3 additions & 3 deletions tests/binary_test.ts → src/tests/binary_test.ts
Expand Up @@ -13,9 +13,9 @@
* limitations under the License.
*/

import { assertEquals } from "https://deno.land/std@0.221.0/assert/mod.ts";
import { createInbox, Msg } from "../src/mod.ts";
import { deferred } from "../nats-base-client/internal_mod.ts";
import { assertEquals } from "jsr:@std/assert";
import { createInbox, deferred } from "../mod.ts";
import type { Msg } from "../mod.ts";
import { cleanup, setup } from "./helpers/mod.ts";

function macro(input: Uint8Array) {
Expand Down
8 changes: 2 additions & 6 deletions tests/buffer_test.ts → src/tests/buffer_test.ts
Expand Up @@ -7,17 +7,13 @@
// This code removes all Deno specific functionality to enable its use
// in a browser environment

import {
assert,
assertEquals,
assertThrows,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { assert, assertEquals, assertThrows } from "jsr:@std/assert";
import {
DenoBuffer,
MAX_SIZE,
readAll,
writeAll,
} from "../nats-base-client/internal_mod.ts";
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";

// N controls how many iterations of certain checks are performed.
const N = 100;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/clobber_test.ts → src/tests/clobber_test.ts
Expand Up @@ -14,9 +14,9 @@
*/

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.221.0/assert/mod.ts";
import { DataBuffer } from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import { connect, createInbox } from "../mod.ts";
import { assertEquals } from "jsr:@std/assert";

function makeBuffer(N: number): Uint8Array {
const buf = new Uint8Array(N);
Expand Down
4 changes: 2 additions & 2 deletions tests/codec_test.ts → src/tests/codec_test.ts
Expand Up @@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { JSONCodec, StringCodec } from "../nats-base-client/codec.ts";
import { assertEquals } from "https://deno.land/std@0.221.0/assert/mod.ts";
import { JSONCodec, StringCodec } from "../mod.ts";
import { assertEquals } from "jsr:@std/assert";

Deno.test("codec - string", () => {
const sc = StringCodec();
Expand Down
4 changes: 2 additions & 2 deletions tests/databuffer_test.ts → src/tests/databuffer_test.ts
Expand Up @@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { assertEquals } from "https://deno.land/std@0.221.0/assert/mod.ts";
import { DataBuffer } from "../nats-base-client/internal_mod.ts";
import { assertEquals } from "jsr:@std/assert";
import { DataBuffer } from "jsr:@nats-io/nats-core@3.0.0-11/internal";

Deno.test("databuffer - empty", () => {
const buf = new DataBuffer();
Expand Down
4 changes: 2 additions & 2 deletions tests/disconnect_test.ts → src/tests/disconnect_test.ts
Expand Up @@ -13,9 +13,9 @@
* limitations under the License.
*/

import { connect } from "../src/mod.ts";
import { connect } from "../mod.ts";
import { Lock, NatsServer } from "./helpers/mod.ts";
import type { NatsConnectionImpl } from "../nats-base-client/internal_mod.ts";
import type { NatsConnectionImpl } from "jsr:@nats-io/nats-core@3.0.0-11/internal";

Deno.test("disconnect - close handler is called on close", async () => {
const ns = await NatsServer.start();
Expand Down
17 changes: 8 additions & 9 deletions tests/doublesubs_test.ts → src/tests/doublesubs_test.ts
Expand Up @@ -13,21 +13,20 @@
* limitations under the License.
*/
import { NatsServer } from "./helpers/launcher.ts";
import { connect } from "../src/connect.ts";
import {
connect,
deferred,
Empty,
Events,
headers,
NatsConnectionImpl,
StringCodec,
} from "../nats-base-client/internal_mod.ts";
import {
assertArrayIncludes,
assertEquals,
} from "https://deno.land/std@0.221.0/assert/mod.ts";
import { extend } from "../nats-base-client/util.ts";
import { join, resolve } from "https://deno.land/std@0.221.0/path/mod.ts";
} from "../mod.ts";
import type {
NatsConnectionImpl,
} from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import { extend } from "jsr:@nats-io/nats-core@3.0.0-11/internal";
import { assertArrayIncludes, assertEquals } from "jsr:@std/assert";
import { join, resolve } from "jsr:@std/path";

async function runDoubleSubsTest(tls: boolean) {
const cwd = Deno.cwd();
Expand Down

0 comments on commit ce18121

Please sign in to comment.