Skip to content

Commit

Permalink
try fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Aug 27, 2024
1 parent fbd7280 commit 2cbf4ee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/test/integration/logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ describe('LogDatabase CRUD', () => {
await new Promise((resolve) => setTimeout(resolve, 1000)) // Delay to allow log to be processed

// Define the time frame for the log retrieval
const startTime = new Date(Date.now() - 5000) // 5 seconds ago
const startTime = new Date(Date.now() - 3000) // 3 seconds ago
const endTime = new Date() // current time

// Retrieve the latest log entry
let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 10)
let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 200)
logs = logs.filter((log) => log.message === newLogEntry.message)

expect(logs?.length).to.equal(1)
Expand All @@ -145,11 +145,15 @@ describe('LogDatabase CRUD', () => {
await new Promise((resolve) => setTimeout(resolve, 1000)) // Delay to allow log to be processed

// Define the time frame for the log retrieval
const startTime = new Date(Date.now() - 5000) // 5 seconds ago
const startTime = new Date(Date.now() - 3000) // 3 seconds ago
const endTime = new Date() // current time

// we cannot predict the amount of logs wriiten on DB (Typesense adds tons on its own), so we need:
// 1 ) set a smaller interval
// 2 ) retrieve a bigger number of logs
// 3 ) filter the appropriate message
// Retrieve the latest log entry
let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 10)
let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 200)
logs = logs.filter((log) => log.message.includes(newLogEntry.message))

expect(logs?.length).to.equal(1)
Expand Down

0 comments on commit 2cbf4ee

Please sign in to comment.