Skip to content

Tests should use test database instead of dev database #412

Description

@kbighorse

Problem

Tests were connecting to the dev database (ocotilloapi_dev) instead of the test database (ocotilloapi_test).

Root Cause

In db/engine.py, load_dotenv(override=True) overwrites the POSTGRES_DB=ocotilloapi_test environment variable set by the test framework in tests/__init__.py with the value from .env (typically ocotilloapi_dev).

Impact

  • Tests may pollute or read from dev database
  • Test isolation is compromised
  • Unexpected test failures due to database state mismatches

Fix

Change load_dotenv(override=True) to load_dotenv(override=False) so pre-set environment variables (from the test framework) are preserved.

Affected Files

  • db/engine.py
  • tests/__init__.py (sets test database)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions