mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-21 20:19:35 +00:00
* change all usage of std.options.Option[T] to results.Opt[T] * fix broken apps and examples (to validate refactor) * removed all std/options code added for libp2p v2 migration * add broker Opt codec to persistency/backend_comm.nim * add a readValue overload for Opt[T] in tools/confutils/cli_args.nim * keep Option where required (Presto, confutils' config_file.nim) * Change generateRlnProof error handling * Fix imports
59 lines
1.6 KiB
Nim
59 lines
1.6 KiB
Nim
import results, testutils/unittests
|
|
|
|
import
|
|
logos_delivery/waku/node/peer_manager/peer_store/migrations,
|
|
../../waku_archive/archive_utils,
|
|
../../testlib/[simple_mock]
|
|
|
|
import std/[tables, strutils, os], results, chronicles
|
|
|
|
import
|
|
logos_delivery/waku/common/databases/db_sqlite,
|
|
logos_delivery/waku/common/databases/common
|
|
|
|
suite "Migrations":
|
|
test "migrate ok":
|
|
# Given the db_sqlite.migrate function returns ok
|
|
let backup = db_sqlite.migrate
|
|
mock(db_sqlite.migrate):
|
|
proc mockedMigrate(
|
|
db: SqliteDatabase, targetVersion: int64, migrationsScriptsDir: string
|
|
): DatabaseResult[void] =
|
|
ok()
|
|
|
|
mockedMigrate
|
|
|
|
# When we call the migrate function
|
|
let migrationResult = migrations.migrate(newSqliteDatabase(), 1)
|
|
|
|
# Then we expect the result to be ok
|
|
check:
|
|
migrationResult == DatabaseResult[void].ok()
|
|
|
|
# Cleanup
|
|
mock(db_sqlite.migrate):
|
|
backup
|
|
|
|
test "migrate error":
|
|
# Given the db_sqlite.migrate function returns an error
|
|
let backup = db_sqlite.migrate
|
|
mock(db_sqlite.migrate):
|
|
proc mockedMigrate(
|
|
db: SqliteDatabase, targetVersion: int64, migrationsScriptsDir: string
|
|
): DatabaseResult[void] =
|
|
err("mock error")
|
|
|
|
mockedMigrate
|
|
|
|
# When we call the migrate function
|
|
let migrationResult = migrations.migrate(newSqliteDatabase(), 1)
|
|
|
|
# Then we expect the result to be an error
|
|
check:
|
|
migrationResult ==
|
|
DatabaseResult[void].err("failed to execute migration scripts: mock error")
|
|
|
|
# Cleanup
|
|
mock(db_sqlite.migrate):
|
|
backup
|