Skip to content

Commit

Permalink
test_driver_postgres: enhance test coverage, multiple and single topic (
Browse files Browse the repository at this point in the history
#2301)

Co-authored-by: Abhimanyu <ABresting@users.noreply.github.com>
  • Loading branch information
Ivansete-status and ABresting authored Dec 19, 2023
1 parent d01904e commit 8b37919
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/waku_archive/test_driver_postgres_query.nim
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,36 @@ suite "Postgres driver - query by content topic":
require (await driver.put(DefaultPubsubTopic, msg, computeDigest(msg), computeMessageHash(DefaultPubsubTopic, msg), msg.timestamp)).isOk()

## When
let res = await driver.getMessages(
var res = await driver.getMessages(
contentTopic= @[contentTopic1, contentTopic2],
pubsubTopic=some(DefaultPubsubTopic),
maxPageSize=2,
ascendingOrder=true
ascendingOrder=true,
startTime=some(ts(00)),
endTime=some(ts(40))
)

## Then
assert res.isOk(), res.error
var filteredMessages = res.tryGet().mapIt(it[1])
check filteredMessages == expected[2..3]

let filteredMessages = res.tryGet().mapIt(it[1])
check:
filteredMessages == expected[2..3]
## When
## This is very similar to the previous one but we enforce to use the prepared
## statement by querying one single content topic
res = await driver.getMessages(
contentTopic= @[contentTopic1],
pubsubTopic=some(DefaultPubsubTopic),
maxPageSize=2,
ascendingOrder=true,
startTime=some(ts(00)),
endTime=some(ts(40))
)

## Then
assert res.isOk(), res.error
filteredMessages = res.tryGet().mapIt(it[1])
check filteredMessages == @[expected[2]]

## Cleanup
(await driver.close()).expect("driver to close")
Expand Down

0 comments on commit 8b37919

Please sign in to comment.