Skip to content

Commit

Permalink
DEV: add buffer unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Jul 9, 2024
1 parent 1a8dd19 commit 4fa99d5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,23 @@ test('Test stale buffered data', async () => {
expect(r).toBeDefined()
expect(r.points[0].value).toBe(7)
})


test('Buffered metric return', async () => {
let metrics = new CustomMetrics({client, table, log: true})
let timestamp = new Date(2000, 0, 1).getTime()
let interval = 1

for (let i = 0; i < 5; i++) {
let metric = await metrics.emit('test/buffer', 'ReturnMetric', 1, [], {
buffer: {sum: 5}, timestamp
})
if (i < 4) {
expect(metric).toBeDefined()
expect(metric.spans.length).toBe(1)
} else {
expect(metric.spans.length).toBe(6)
}
timestamp += interval * 1000
}
})

0 comments on commit 4fa99d5

Please sign in to comment.