fix(tests): update orgTokenValidateQuery mock — Validate reads 3 columns (#1366)

This commit is contained in:
molecule-ai[bot] 2026-04-21 12:15:36 +00:00 committed by GitHub
parent cefe4c9dea
commit 51d6271ed4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -473,8 +473,8 @@ func TestAdminAuth_InvalidBearer_Returns401(t *testing.T) {
// token (org_id="ws-org-1").
// ────────────────────────────────────────────────────────────────────────────
// orgTokenValidateQuery is declared in wsauth_middleware_org_id_test.go
// and reused here — same package, shared const, matched by sqlmock regex.
// orgTokenValidateQuery is matched for orgtoken.Validate().
const orgTokenValidateQuery = "SELECT id, prefix, org_id::text FROM org_api_tokens"
// orgTokenOrgIDQuery is matched for the org_id lookup added in the F1097 fix.
const orgTokenOrgIDQuery = "SELECT org_id::text FROM org_api_tokens"
@ -525,8 +525,8 @@ func TestAdminAuth_OrgToken_SetsOrgID(t *testing.T) {
// (ValidateAnyToken), so ValidateAnyToken is NOT called here.
mock.ExpectQuery(orgTokenValidateQuery).
WithArgs(orgTokenHash[:]).
WillReturnRows(sqlmock.NewRows([]string{"id", "prefix"}).
AddRow("tok-org-1", "tok-org-1"))
WillReturnRows(sqlmock.NewRows([]string{"id", "prefix", "org_id"}).
AddRow("tok-org-1", "tok-org-1", nil))
// Best-effort last_used_at UPDATE (after Validate).
mock.ExpectExec(orgTokenLastUsedQuery).