mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
pytest: Add test for key-value style postgresql DSNs
This commit is contained in:
committed by
Rusty Russell
parent
1d9e7cf079
commit
d9ba39d2cb
@@ -281,3 +281,20 @@ def test_optimistic_locking(node_factory, bitcoind):
|
||||
l1.rpc.newaddr()
|
||||
|
||||
assert(l1.daemon.is_in_log(r'Optimistic lock on the database failed'))
|
||||
|
||||
|
||||
@unittest.skipIf(os.environ.get('TEST_DB_PROVIDER', None) != 'postgres', "Only applicable to postgres")
|
||||
def test_psql_key_value_dsn(node_factory, db_provider, monkeypatch):
|
||||
from pyln.testing.db import PostgresDb
|
||||
|
||||
# Override get_dsn method to use the key-value style DSN
|
||||
def get_dsn(self):
|
||||
print("hello")
|
||||
return "postgres://host=127.0.0.1 port={port} user=postgres password=password dbname={dbname}".format(
|
||||
port=self.port, dbname=self.dbname
|
||||
)
|
||||
|
||||
monkeypatch.setattr(PostgresDb, "get_dsn", get_dsn)
|
||||
l1 = node_factory.get_node()
|
||||
opt = [o for o in l1.daemon.cmd_line if '--wallet' in o][0]
|
||||
assert('host=127.0.0.1' in opt)
|
||||
|
||||
Reference in New Issue
Block a user