Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.git
dist
tsconfig.tsbuildinfo
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
54 changes: 27 additions & 27 deletions __tests__/__snapshots__/crontab.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`parses crontab file correctly 1`] = `
Array [
Object {
[
{
"identifier": "simple",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": undefined,
"jobKeyMode": undefined,
Expand All @@ -17,10 +17,10 @@ Array [
"task": "simple",
Symbol(isParsed): true,
},
Object {
{
"identifier": "every_day_at_4_am",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": undefined,
"jobKeyMode": undefined,
Expand All @@ -32,10 +32,10 @@ Array [
"task": "every_day_at_4_am",
Symbol(isParsed): true,
},
Object {
{
"identifier": "every_sunday_at_4_am",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": undefined,
"jobKeyMode": undefined,
Expand All @@ -47,10 +47,10 @@ Array [
"task": "every_sunday_at_4_am",
Symbol(isParsed): true,
},
Object {
{
"identifier": "sunday_7",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": undefined,
"jobKeyMode": undefined,
Expand All @@ -62,46 +62,46 @@ Array [
"task": "every_sunday_at_4_am",
Symbol(isParsed): true,
},
Object {
{
"identifier": "every_tuesday_at_4_am",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": undefined,
"jobKeyMode": undefined,
"maxAttempts": undefined,
"priority": undefined,
"queueName": undefined,
},
"payload": Object {
"payload": {
"isTuesday": true,
},
"task": "every_tuesday_at_4_am",
Symbol(isParsed): true,
},
Object {
{
"identifier": "stuff",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 2685660000,
"jobKey": undefined,
"jobKeyMode": undefined,
"maxAttempts": 3,
"priority": 3,
"queueName": "my_queue",
},
"payload": Object {
"myExtraPayload": Object {
"payload": {
"myExtraPayload": {
"stuff": "here with # hash char",
},
},
"task": "one",
Symbol(isParsed): true,
},
Object {
{
"identifier": "lots_of_spaces",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": undefined,
"jobKeyMode": undefined,
Expand All @@ -113,10 +113,10 @@ Array [
"task": "lots_of_spaces",
Symbol(isParsed): true,
},
Object {
{
"identifier": "with_key",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": "my_key",
"jobKeyMode": "replace",
Expand All @@ -128,10 +128,10 @@ Array [
"task": "with_key",
Symbol(isParsed): true,
},
Object {
{
"identifier": "with_key_and_mode",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": "my_key",
"jobKeyMode": "preserve_run_at",
Expand All @@ -143,10 +143,10 @@ Array [
"task": "with_key_and_mode",
Symbol(isParsed): true,
},
Object {
{
"identifier": "nested/task",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": "my_key",
"jobKeyMode": "preserve_run_at",
Expand All @@ -158,10 +158,10 @@ Array [
"task": "nested/task",
Symbol(isParsed): true,
},
Object {
{
"identifier": "nested/folder/task",
"match": [Function],
"options": Object {
"options": {
"backfillPeriod": 0,
"jobKey": "my_key",
"jobKeyMode": "preserve_run_at",
Expand Down
17 changes: 9 additions & 8 deletions __tests__/batchJobs.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { Task, TaskList, WorkerSharedOptions } from "../src/interfaces";
import { runTaskListOnce } from "../src/main";
import {
Expand Down Expand Up @@ -45,20 +46,20 @@ test("on success, deletes job", () =>

const job3: Task = jest.fn((o) => {
expect(o).toMatchInlineSnapshot(`
Array [
Object {
[
{
"a": 1,
},
Object {
{
"a": 2,
},
Object {
{
"a": 3,
},
]
`);
});
const job4: Task = jest.fn();
const job4: Task = jest.fn(() => {});
const tasks: TaskList = {
job3,
job4,
Expand All @@ -83,7 +84,7 @@ test("on failure, re-enqueues job", () =>
const job3: Task = jest.fn(() => {
throw new Error("RETRY");
});
const job4: Task = jest.fn();
const job4: Task = jest.fn(() => {});
const tasks: TaskList = {
job3,
job4,
Expand Down Expand Up @@ -115,7 +116,7 @@ test("on partial fail, re-enqueues job with just failed elements", () =>
a % 2 === 1 ? Promise.reject(new Error(String(a))) : null,
);
});
const job4: Task = jest.fn();
const job4: Task = jest.fn(() => {});
const tasks: TaskList = {
job3,
job4,
Expand Down Expand Up @@ -147,7 +148,7 @@ test("on partial fail (promise), re-enqueues job with just failed elements", ()
a % 2 === 1 ? Promise.reject(new Error(String(a))) : null,
);
});
const job4: Task = jest.fn();
const job4: Task = jest.fn(() => {});
const tasks: TaskList = {
job3,
job4,
Expand Down
3 changes: 2 additions & 1 deletion __tests__/events.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { jest } from "@jest/globals";
import { EventEmitter } from "events";
import { Pool } from "pg";
import type { Pool } from "pg";

import { run } from "../src";
import deferred, { Deferred } from "../src/deferred";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rand } from "../blah.js";
import { rand } from "../blah.mjs";
export default (_payload, helpers) => {
helpers.logger.debug(rand());
return "some sausages";
Expand Down
11 changes: 6 additions & 5 deletions __tests__/forbiddenFlags.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import {
makeWorkerUtils,
runTaskListOnce,
Expand Down Expand Up @@ -28,7 +29,7 @@ test("supports the flags API", () =>
expect(jobs[0]).toHaveProperty("flags");
expect(jobs[0].flags).toEqual({ a: true, b: true });

const task: Task = jest.fn();
const task: Task = jest.fn(() => {});
const taskList: TaskList = { task };
await runTaskListOnce(options, taskList, pgClient);
}));
Expand All @@ -49,8 +50,8 @@ test.each([
withPgPool(async (pgPool) => {
await reset(pgPool, options);

const shouldRun = jest.fn();
const shouldSkip = jest.fn();
const shouldRun = jest.fn(() => {});
const shouldSkip = jest.fn(() => {});

const job: Task = async (_payload, helpers) => {
const flags = helpers.job.flags || {};
Expand Down Expand Up @@ -111,8 +112,8 @@ test.each([
withPgPool(async (pgPool) => {
await reset(pgPool, options);

const ranWithoutDFlag = jest.fn();
const ranWithDFlag = jest.fn();
const ranWithoutDFlag = jest.fn(() => {});
const ranWithDFlag = jest.fn(() => {});

const job: Task = async (_payload, helpers) => {
const flags = helpers.job.flags || {};
Expand Down
Loading
Loading