Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl committed Aug 1, 2018
1 parent b81dc39 commit 8622f58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ language: python
cache: pip

before_script:
- psql -c 'create database travis;' -U postgres
- psql -c 'create database synapse_base;' -U postgres
- git remote set-branches --add origin develop
- git fetch origin develop
Expand Down
9 changes: 6 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
# It requires you to have a local postgres database called synapse_test, within
# which ALL TABLES WILL BE DROPPED
USE_POSTGRES_FOR_TESTS = os.environ.get("SYNAPSE_POSTGRES", False)
POSTGRES_USER = os.environ.get("SYNAPSE_POSTGRES_USER", "postgres")


def setupdb():
Expand All @@ -50,6 +51,7 @@ def setupdb():
"name": "psycopg2",
"args": {
"database": "synapse_base",
"user": POSTGRES_USER,
"cp_min": 1,
"cp_max": 5,
},
Expand All @@ -58,7 +60,7 @@ def setupdb():
config.password_providers = []
config.database_config = pgconfig
db_engine = create_engine(pgconfig)
db_conn = db_engine.module.connect("")
db_conn = db_engine.module.connect("user=%s" % (POSTGRES_USER,))
db_conn.autocommit = True
cur = db_conn.cursor()
cur.execute("DROP DATABASE IF EXISTS synapse_base;")
Expand All @@ -68,7 +70,7 @@ def setupdb():
db_conn.close()

# Set up in the db
db_conn = db_engine.module.connect("dbname=synapse_base")
db_conn = db_engine.module.connect("dbname=synapse_base user=%s" % (POSTGRES_USER,))
cur = db_conn.cursor()
_get_or_create_schema_state(cur, db_engine)
_setup_new_database(cur, db_engine)
Expand Down Expand Up @@ -129,6 +131,7 @@ def setup_test_homeserver(name="test", datastore=None, config=None, reactor=None
"name": "psycopg2",
"args": {
"database": "synapse_test",
"user": POSTGRES_USER,
"cp_min": 1,
"cp_max": 5,
},
Expand All @@ -149,7 +152,7 @@ def setup_test_homeserver(name="test", datastore=None, config=None, reactor=None
# Create the database before we actually try and connect to it, based off
# the template database we generate in setupdb()
if datastore is None and isinstance(db_engine, PostgresEngine):
db_conn = db_engine.module.connect("dbname=synapse_base")
db_conn = db_engine.module.connect("dbname=synapse_base user=%s" % (POSTGRES_USER,))
db_conn.autocommit = True
cur = db_conn.cursor()
cur.execute("DROP DATABASE IF EXISTS synapse_test;")
Expand Down

0 comments on commit 8622f58

Please sign in to comment.