Skip to content

Commit

Permalink
Upgrade packages, including ioredis (#836)
Browse files Browse the repository at this point in the history
* Upgrade packages, including `ioredis`

* longer test timeout
  • Loading branch information
evantahler committed Jul 18, 2022
1 parent 87e97e0 commit 7395c49
Show file tree
Hide file tree
Showing 9 changed files with 1,739 additions and 2,752 deletions.
6 changes: 3 additions & 3 deletions __tests__/core/connection.ts
@@ -1,4 +1,4 @@
import * as IORedis from "ioredis";
import Redis from "ioredis";
import { Connection } from "../../src";
import specHelper from "../utils/specHelper";

Expand Down Expand Up @@ -35,9 +35,9 @@ describe("connection", () => {
});

let prefixedConnection: Connection;
let prefixedRedis: IORedis.Redis;
let prefixedRedis: Redis;
beforeAll(async () => {
prefixedRedis = new IORedis(null, null, {
prefixedRedis = new Redis(null, null, {
keyPrefix: "customNamespace:",
db: db,
});
Expand Down
52 changes: 28 additions & 24 deletions __tests__/core/connectionError.ts
Expand Up @@ -2,31 +2,35 @@ import { Connection } from "../../src";
import specHelper from "../utils/specHelper";

describe("connection error", () => {
test("can provide an error if connection failed", async () => {
await new Promise(async (resolve) => {
const connectionDetails = {
pkg: specHelper.connectionDetails.pkg,
host: "wronghostname",
password: specHelper.connectionDetails.password,
port: specHelper.connectionDetails.port,
database: specHelper.connectionDetails.database,
namespace: specHelper.connectionDetails.namespace,
options: { maxRetriesPerRequest: 1 },
};
test(
"can provide an error if connection failed",
async () => {
await new Promise(async (resolve) => {
const connectionDetails = {
pkg: specHelper.connectionDetails.pkg,
host: "wronghostname",
password: specHelper.connectionDetails.password,
port: specHelper.connectionDetails.port,
database: specHelper.connectionDetails.database,
namespace: specHelper.connectionDetails.namespace,
options: { maxRetriesPerRequest: 1 },
};

const brokenConnection = new Connection(connectionDetails);
const brokenConnection = new Connection(connectionDetails);

brokenConnection.on("error", async (error) => {
expect(error.message).toMatch(
/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|EAI_AGAIN/
);
});
brokenConnection.on("error", async (error) => {
expect(error.message).toMatch(
/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|EAI_AGAIN/
);
});

try {
await brokenConnection.connect();
} catch (error) {
setTimeout(resolve, 3 * 1000);
}
});
});
try {
await brokenConnection.connect();
} catch (error) {
setTimeout(resolve, 3 * 1000);
}
});
},
60 * 1000
);
});
4 changes: 2 additions & 2 deletions __tests__/integration/ioredis-mock.ts
Expand Up @@ -2,8 +2,8 @@ import { Queue, Worker, Scheduler, Job } from "../../src";
import specHelper from "../utils/specHelper";

// import * as RedisMock from "ioredis-mock"; // TYPE HACK!
import * as IORedis from "ioredis";
const RedisMock: typeof IORedis = require("ioredis-mock");
import Redis from "ioredis";
const RedisMock: typeof Redis = require("ioredis-mock");

// for ioredis-mock, we need to re-use a shared connection
// setting "pkg" is important!
Expand Down
6 changes: 3 additions & 3 deletions __tests__/utils/specHelper.ts
@@ -1,4 +1,4 @@
import * as IORedis from "ioredis";
import Redis from "ioredis";
import * as NodeResque from "../../src/index";

const namespace = `resque-test-${process.env.JEST_WORKER_ID || 0}`;
Expand All @@ -11,7 +11,7 @@ const SpecHelper = {
queue: queue,
timeout: 500,
smallTimeout: 3,
redis: null as IORedis.Redis,
redis: null as Redis,
connectionDetails: {
pkg: pkg,
host: process.env.REDIS_HOST || "127.0.0.1",
Expand All @@ -26,7 +26,7 @@ const SpecHelper = {
if (!this.connectionDetails.options) this.connectionDetails.options = {};
this.connectionDetails.options.db =
this.connectionDetails?.options?.database;
this.redis = new IORedis(
this.redis = new Redis(
this.connectionDetails.port,
this.connectionDetails.host,
this.connectionDetails.options
Expand Down

0 comments on commit 7395c49

Please sign in to comment.