fix postgres db connection

This commit is contained in:
Lex Berezhny 2020-06-27 22:31:49 -04:00
parent f2ff4410dc
commit 81926a42f9

View file

@ -42,10 +42,11 @@ class BasicBlockchainTestCase(AsyncioTestCase):
db = Database.temp_sqlite_regtest(chain.ledger.conf.lbrycrd_dir) db = Database.temp_sqlite_regtest(chain.ledger.conf.lbrycrd_dir)
elif db_driver.startswith('postgres') or db_driver.startswith('psycopg'): elif db_driver.startswith('postgres') or db_driver.startswith('psycopg'):
db_name = f'lbry_test_chain' db_name = f'lbry_test_chain'
meta_db = Database.from_url(f'postgresql:///postgres') db_connection = 'postgres:postgres@localhost:5432'
meta_db = Database.from_url(f'postgresql://{db_connection}/postgres')
await meta_db.drop(db_name) await meta_db.drop(db_name)
await meta_db.create(db_name) await meta_db.create(db_name)
db = Database.temp_from_url_regtest(f'postgresql:///{db_name}', chain.ledger.conf.lbrycrd_dir) db = Database.temp_from_url_regtest(f'postgresql://{db_connection}/{db_name}', chain.ledger.conf.lbrycrd_dir)
else: else:
raise RuntimeError(f"Unsupported database driver: {db_driver}") raise RuntimeError(f"Unsupported database driver: {db_driver}")
self.addCleanup(remove_tree, db.ledger.conf.data_dir) self.addCleanup(remove_tree, db.ledger.conf.data_dir)