Skip to content

Commit be80c55

Browse files
committed
added env var for MySQL, PostgreSQL hosts
1 parent b813f9f commit be80c55

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Diff for: .github/workflows/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
pip install mysqlclient psycopg2-binary
3131
- name: Run tests
3232
run: python tests/sql.py
33+
env:
34+
MYSQL_HOST: 127.0.0.1
35+
POSTGRESQL_HOST: 127.0.0.1
3336
- name: Install pypa/build
3437
run: python -m pip install build --user
3538
- name: Build a binary wheel and a source tarball

Diff for: docker-compose.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ services:
66
- mysql
77
- postgres
88
environment:
9-
MYSQL_DATABASE: code50
109
MYSQL_HOST: mysql
11-
MYSQL_PASSWORD: crimson
12-
MYSQL_USERNAME: root
13-
OAUTHLIB_INSECURE_TRANSPORT: 1
10+
POSTGRESQL_HOST: postgresql
1411
links:
1512
- mysql
1613
- postgres

Diff for: tests/sql.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import sys
34
import unittest
45
import warnings
@@ -155,7 +156,7 @@ def tearDownClass(self):
155156
class MySQLTests(SQLTests):
156157
@classmethod
157158
def setUpClass(self):
158-
self.db = SQL("mysql://root@mysql/test")
159+
self.db = SQL(f"mysql://root@{os.getenv('MYSQL_HOST')}/test")
159160

160161
def setUp(self):
161162
self.db.execute("CREATE TABLE IF NOT EXISTS cs50 (id INTEGER NOT NULL AUTO_INCREMENT, val VARCHAR(16), bin BLOB, PRIMARY KEY (id))")
@@ -165,7 +166,7 @@ def setUp(self):
165166
class PostgresTests(SQLTests):
166167
@classmethod
167168
def setUpClass(self):
168-
self.db = SQL("postgresql://postgres:postgres@postgres/test")
169+
self.db = SQL(f"postgresql://postgres:postgres@{os.getenv('POSTGRESQL_HOST')}/test")
169170

170171
def setUp(self):
171172
self.db.execute("CREATE TABLE IF NOT EXISTS cs50 (id SERIAL PRIMARY KEY, val VARCHAR(16), bin BYTEA)")

0 commit comments

Comments
 (0)