From 045a23360e47b5ba5100b99b65bf2e9ee1c3eba8 Mon Sep 17 00:00:00 2001 From: Michael Levin Date: Thu, 2 Jan 2025 16:05:58 -0500 Subject: [PATCH] fix tests --- deploy/cron.js | 9 +++++---- test/app_config.test.js | 6 +++--- test/index.test.js | 6 +++++- test/support/database.js | 5 ++++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/deploy/cron.js b/deploy/cron.js index 6fcafc4c..4bc3dc1a 100644 --- a/deploy/cron.js +++ b/deploy/cron.js @@ -85,20 +85,21 @@ const calculateNextDailyRunTimeOffset = () => { }; /** - * All scripts run immediately upon application start (with a 10 second delay + * All scripts run immediately upon application start (with a 60 second delay * between each so that they don't all run at once), then run again at intervals * going forward. */ setTimeout(realtime_run, 1000 * 10); -setTimeout(hourly_run, 1000 * 20); -setTimeout(daily_run, 1000 * 30); -setTimeout(api_run, 1000 * 40); +setTimeout(hourly_run, 1000 * 70); +setTimeout(daily_run, 1000 * 130); +setTimeout(api_run, 1000 * 190); // daily // Runs at 10 AM UTC, then every 24 hours afterwards setTimeout(() => { daily_run(); setInterval(daily_run, 1000 * 60 * 60 * 24); + setTimeout(hourly_run, 1000 * 60); // API api_run(); setInterval(api_run, 1000 * 60 * 60 * 24); diff --git a/test/app_config.test.js b/test/app_config.test.js index f5e8a018..418b3a4c 100644 --- a/test/app_config.test.js +++ b/test/app_config.test.js @@ -595,7 +595,7 @@ describe("AppConfig", () => { }); }); - describe(".postgres", () => { + describe(".knexConfig", () => { describe("when NODE_ENV is set", () => { beforeEach(() => { process.env.NODE_ENV = "production"; @@ -606,7 +606,7 @@ describe("AppConfig", () => { }); it("returns the knexfile connection details for the node environment", () => { - expect(subject.postgres).to.equal(knexfile["production"].connection); + expect(subject.knexConfig).to.equal(knexfile["production"]); }); }); @@ -616,7 +616,7 @@ describe("AppConfig", () => { }); it("returns the knexfile connection details for the development environment", () => { - expect(subject.postgres).to.equal(knexfile["development"].connection); + expect(subject.knexConfig).to.equal(knexfile["development"]); }); }); }); diff --git a/test/index.test.js b/test/index.test.js index 59d388a6..e52ef163 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -134,7 +134,11 @@ describe("index", () => { }); it("logs that there was a processing error", () => { - expect(logger.error.calledWith("Encountered an error")).to.equal(true); + expect( + logger.error.calledWith( + "Encountered an error during report processing", + ), + ).to.equal(true); }); it("logs the error", () => { diff --git a/test/support/database.js b/test/support/database.js index ed1ebf08..36a1b371 100644 --- a/test/support/database.js +++ b/test/support/database.js @@ -6,4 +6,7 @@ const resetSchema = (db) => { return db(PostgresPublisher.ANALYTICS_DATA_TABLE_NAME).delete(); }; -module.exports = { connection: new AppConfig().postgres, resetSchema }; +module.exports = { + connection: new AppConfig().knexConfig.connection, + resetSchema, +};