Skip to content

Commit

Permalink
Merge pull request #28 from quirrel-dev/fix-27
Browse files Browse the repository at this point in the history
Fix 27
  • Loading branch information
Skn0tt authored Nov 27, 2020
2 parents 9685de8 + 2c5ab57 commit a6d4935
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 0 additions & 4 deletions api/src/scheduler/jobs-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ export class JobsRepo {
runAt = cron(runAt ?? new Date(), repeat.cron);
}

if (repeat?.every) {
runAt = new Date();
}

if (typeof repeat?.times === "number" && repeat.times < 1) {
return;
}
Expand Down
26 changes: 26 additions & 0 deletions api/test/jobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ function testAgainst(backend: "Redis" | "Mock") {
expect(bodies).toEqual([]);
});

test("regression #27: delay & repeat.every", async () => {
await request(quirrel)
.post("/queues/" + endpoint)
.send({
body: "delay & repeat.every",
delay: 100,
repeat: {
every: 100,
times: 2,
},
})
.expect(201);

await delay(75);

expect(bodies).toEqual([]);

await delay(75);

expect(bodies).toEqual(["delay & repeat.every"]);

await delay(75);

expect(bodies).toEqual(["delay & repeat.every", "delay & repeat.every"]);
});

describe("cron jobs", () => {
test("work", async () => {
await request(quirrel)
Expand Down

0 comments on commit a6d4935

Please sign in to comment.