From 6d13fa425a7fa4468103da3570a145e9df30018b Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Fri, 3 Jul 2026 18:13:40 +0300 Subject: [PATCH] fix(backend): swap db name in URL-style test DSN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The integration suite creates a per-run database and rewrites the admin DSN to point at it via replaceDSNDatabase. The URL-style branch was a stub that returned the DSN unchanged, so with a URL DSN every test ran against the shared `postgres` database instead of its own — no isolation. The first test to create a given user/object won; the rest collided on unique constraints, surfacing as cascades of 500s (and ImportFromFolder seeing accumulated rows). CI passes TANABATA_TEST_ADMIN_DSN in URL form, so this only broke in the deploy pipeline, not local key=value runs. Parse the URL and swap its path to the per-run database. Co-Authored-By: Claude Opus 4.8 --- backend/internal/integration/server_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/internal/integration/server_test.go b/backend/internal/integration/server_test.go index 58a52e3..636ebd1 100644 --- a/backend/internal/integration/server_test.go +++ b/backend/internal/integration/server_test.go @@ -1614,7 +1614,13 @@ func replaceDSNDatabase(dsn, newDB string) string { } return dsn + " dbname=" + newDB } - // URL style: not used in our defaults, but handled for completeness. + // URL style (e.g. postgres://user:pass@host:port/dbname?opts): the database + // is the URL path. CI passes this form via TANABATA_TEST_ADMIN_DSN, so it + // must swap the path to point the suite at its per-run database. + if u, err := url.Parse(dsn); err == nil { + u.Path = "/" + newDB + return u.String() + } return dsn }