Skip to content

Commit

Permalink
test_driver_postgres.nim: new unit test (checking duplicate insertion)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed May 30, 2023
1 parent 8f1ec50 commit 3bc28fb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/v2/waku_archive/test_driver_postgres.nim
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,37 @@ suite "Postgres driver":

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

asyncTest "insert true duplicated messages":
# Validates that two completely equal messages can not be stored.
## Given
let driverRes = PostgresDriver.new(storeMessageDbUrl)

require:
driverRes.isOk()

discard driverRes.get().reset()
discard driverRes.get().init()

let driver: ArchiveDriver = driverRes.tryGet()
require:
not driver.isNil()

let now = now()

let msg1 = fakeWakuMessage(ts = now)
let msg2 = fakeWakuMessage(ts = now)

var putRes = await driver.put(DefaultPubsubTopic,
msg1, computeDigest(msg1), msg1.timestamp)
## Then
require:
putRes.isOk()

putRes = await driver.put(DefaultPubsubTopic,
msg2, computeDigest(msg2), msg2.timestamp)
## Then
require:
not putRes.isOk()


0 comments on commit 3bc28fb

Please sign in to comment.