Skip to content

Commit 3114f57

Browse files
committed
Use postgres database for testing depending on settings
1 parent 20f4e6b commit 3114f57

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django

infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@
7474
DATABASE_NAME = os.path.join(getattr(settings, "PERSISTENT_ROOT", "."), f"{app_name}.sqlite3")
7575
DATABSE_HOST = None
7676
DATABASE_PORT = None
77+
TEST_DATABASE_NAME = os.path.join(getattr(settings, "PERSISTENT_ROOT", "."), "testdb.sqlite3")
7778
elif current_app.harness.database.type == "postgres":
7879
DATABASE_ENGINE = "django.db.backends.postgresql"
7980
DATABASE_NAME = current_app.harness.database.postgres.initialdb
81+
TEST_DATABASE_NAME = f"test_{DATABASE_NAME}"
8082
DATABSE_HOST = current_app.harness.database.name
8183
DATABASE_PORT = current_app.harness.database.postgres.ports[0].port
8284

@@ -91,8 +93,8 @@
9193
"HOST": DATABSE_HOST,
9294
"PORT": DATABASE_PORT,
9395
"TEST": {
94-
"ENGINE": "django.db.backends.sqlite3",
95-
"NAME": os.path.join(getattr(settings, "PERSISTENT_ROOT", "."), "testdb.sqlite3"),
96+
"ENGINE": DATABASE_ENGINE or "django.db.backends.sqlite3",
97+
"NAME": TEST_DATABASE_NAME,
9698
},
9799
},
98100
}

0 commit comments

Comments
 (0)