Skip to content

Commit

Permalink
Try with different mariadb setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed Feb 6, 2024
1 parent 2c8b53f commit c0d06f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/unittests-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:latest
ports:
- 3306
env:
MARIADB_ROOT_PASSWORD: password
MARIADB_DATABASE: test
MARIADB_USER: user
MARIADB_PASSWORD: password
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
matrix:
Expand All @@ -19,9 +30,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install .[dev]
- name: Start mysql
run: |
sudo /etc/init.d/mysql start
- name: Test with coverage
env:
BCL_CONFIG_FILE: config.ini.unittest
Expand Down
9 changes: 2 additions & 7 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@ def database_init(dbname=DATABASE_NAME):
con.close()
return 'postgresql://postgres:postgres@localhost:5432/' + dbname
elif os.getenv('UNITTEST_DATABASE') == 'mysql':
try:
con = mysql.connector.connect(user='root', host='localhost')
credentials = 'root'
except mysql.connector.errors.ProgrammingError:
con = mysql.connector.connect(user='user', host='localhost', password='password')
credentials = 'user:password'
con = mysql.connector.connect(user='user', host='localhost', password='password')
cur = con.cursor()
cur.execute("DROP DATABASE IF EXISTS {}".format(dbname))
cur.execute("CREATE DATABASE {}".format(dbname))
con.commit()
cur.close()
con.close()
return 'mysql://%s@localhost:3306/' % credentials + dbname
return 'mysql://user:password@localhost:3306/' + dbname
else:
dburi = os.path.join(str(BCL_DATABASE_DIR), '%s.sqlite' % dbname)
if os.path.isfile(dburi):
Expand Down
9 changes: 2 additions & 7 deletions tests/test_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,14 @@ def database_init(dbname=DATABASE_NAME):
# return postgresql.url()
return 'testing.postgresql'
elif os.getenv('UNITTEST_DATABASE') == 'mysql':
try:
con = mysql.connector.connect(user='root', host='localhost')
credentials = 'root'
except mysql.connector.errors.ProgrammingError:
con = mysql.connector.connect(user='user', host='localhost', password='password')
credentials = 'user:password'
con = mysql.connector.connect(user='user', host='localhost', password='password')
cur = con.cursor()
cur.execute("DROP DATABASE IF EXISTS {}".format(dbname))
cur.execute("CREATE DATABASE {}".format(dbname))
con.commit()
cur.close()
con.close()
return 'mysql://%s@localhost:3306/' % credentials + dbname
return 'mysql://user:password@localhost:3306/' + dbname
else:
dburi = os.path.join(str(BCL_DATABASE_DIR), '%s.sqlite' % dbname)
if os.path.isfile(dburi):
Expand Down

0 comments on commit c0d06f6

Please sign in to comment.