Skip to content

Commit

Permalink
pytest: Add test for key-value style postgresql DSNs
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and rustyrussell committed Sep 23, 2020
1 parent 1d9e7cf commit d9ba39d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d9ba39d

Please sign in to comment.