Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test_driver_postgres - enhance test coverage, multiple and single topic #2301

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading