diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bd363c2..6179239 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,10 +65,19 @@ jobs: pip freeze - name: Run tests env: - DB_SETTINGS: >- + DB_SETTINGS_ONE: >- { "ENGINE":"django.db.backends.postgresql", - "NAME":"dynamic_db_router", + "NAME":"dynamic_db_router_one", + "USER":"postgres", + "PASSWORD":"postgres", + "HOST":"localhost", + "PORT":"5432" + } + DB_SETTINGS_TWO: >- + { + "ENGINE":"django.db.backends.postgresql", + "NAME":"dynamic_db_router_two", "USER":"postgres", "PASSWORD":"postgres", "HOST":"localhost", diff --git a/settings.py b/settings.py index 4ee9a11..b3edd06 100644 --- a/settings.py +++ b/settings.py @@ -33,6 +33,15 @@ def configure_settings(): else: raise RuntimeError('Unsupported test DB {0}'.format(test_db)) + # Check env for db override (used for github actions) + if os.environ.get('DB_SETTINGS_ONE'): + db_config_one = json.loads(os.environ.get('DB_SETTINGS_ONE')) + + # Check env for db override (used for github actions) + if os.environ.get('DB_SETTINGS_TWO'): + db_config_two = json.loads(os.environ.get('DB_SETTING_TWO')) + + settings.configure( DATABASES={ 'default': db_config_one,