Skip to content

Commit

Permalink
fix: test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakia committed Apr 11, 2024
1 parent 63732a9 commit 54f6836
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
8 changes: 5 additions & 3 deletions api/routes/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ const load_network = async () => {
return response_data
}

cron.schedule('*/5 * * * *', async () => {
await load_network()
})
if (process.env.NODE_ENV !== 'test') {
cron.schedule('*/5 * * * *', async () => {
await load_network()
})
}

router.get('/', async (req, res) => {
const { logger, cache } = req.app.locals
Expand Down
16 changes: 9 additions & 7 deletions api/routes/posts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,14 @@ router.get('/top', async (req, res) => {
}
})

cron.schedule('*/7 * * * *', async () => {
const ages = [72, 168, 720]
for (const age of ages) {
await load_top_posts({ age })
}
await load_trending_posts()
})
if (process.env.NODE_ENV !== 'test') {
cron.schedule('*/7 * * * *', async () => {
const ages = [72, 168, 720]
for (const age of ages) {
await load_top_posts({ age })
}
await load_trending_posts()
})
}

export default router
10 changes: 6 additions & 4 deletions api/routes/representatives/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ const loadRepresentatives = async () => {
return representatives
}

loadRepresentatives()
if (process.env.NODE_ENV !== 'test') {
loadRepresentatives()

cron.schedule('*/5 * * * *', async () => {
await loadRepresentatives()
})
cron.schedule('*/5 * * * *', async () => {
await loadRepresentatives()
})
}

router.get('/', async (req, res) => {
const { logger } = req.app.locals
Expand Down
3 changes: 3 additions & 0 deletions test/global.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global before */
import knex from '#db'
import path, { dirname } from 'path'
import fs from 'fs/promises'
Expand All @@ -10,3 +11,5 @@ export async function mochaGlobalSetup() {
const sql = await fs.readFile(sqlFile, 'utf8')
await knex.raw(sql)
}

before(mochaGlobalSetup)

0 comments on commit 54f6836

Please sign in to comment.