Describe the Bug
internal/pb/v1/database_test.go:
TestNewDatabaseConfig (lines ~11-23) asserts default values ("localhost", "5432", etc.) without clearing any DB_* env vars first, so it fails if the test process already has one set.
TestNewDatabaseConfig_WithEnvVars (lines ~26-49) sets DB_* vars with manual os.Setenv and manually os.Unsetenvs them in t.Cleanup, rather than restoring whatever value (if any) existed beforehand.
Surfaced by CodeRabbit reviewing #517 — this code predates that PR, it just moved location (was portal-backend/v1/database_test.go).
Expected Behavior
Use t.Setenv for every DB_* variable in both tests — set explicit empty values in TestNewDatabaseConfig before asserting defaults, and use t.Setenv (instead of manual os.Setenv/os.Unsetenv) in TestNewDatabaseConfig_WithEnvVars, since t.Setenv automatically restores the prior value after the test and fails the test if run with t.Parallel() misuse.
Version
Surfaced on PR #517 (refactor/portal-backend-restructure).
Additional Context
Flagged 🟡 Minor (Functional Correctness) by CodeRabbit.
Describe the Bug
internal/pb/v1/database_test.go:TestNewDatabaseConfig(lines ~11-23) asserts default values ("localhost","5432", etc.) without clearing anyDB_*env vars first, so it fails if the test process already has one set.TestNewDatabaseConfig_WithEnvVars(lines ~26-49) setsDB_*vars with manualos.Setenvand manuallyos.Unsetenvs them int.Cleanup, rather than restoring whatever value (if any) existed beforehand.Surfaced by CodeRabbit reviewing #517 — this code predates that PR, it just moved location (was
portal-backend/v1/database_test.go).Expected Behavior
Use
t.Setenvfor everyDB_*variable in both tests — set explicit empty values inTestNewDatabaseConfigbefore asserting defaults, and uset.Setenv(instead of manualos.Setenv/os.Unsetenv) inTestNewDatabaseConfig_WithEnvVars, sincet.Setenvautomatically restores the prior value after the test and fails the test if run witht.Parallel()misuse.Version
Surfaced on PR #517 (
refactor/portal-backend-restructure).Additional Context
Flagged 🟡 Minor (Functional Correctness) by CodeRabbit.