test: user-subscription specs fail outside UTC, so the pre-commit hook cannot pass
維護者通常 1 天內回覆
@tejasvasingh2004 已經在處理了。
開始於 2026年10月25日。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- node.js, typescript
- 領域
- testing
研究方向
從 test/unit/repositories/user-subscription-repository.spec.ts 開始,分別在 TZ=UTC 和 TZ=America/Toronto 下執行,以重現五個失敗。追蹤 specs 如何建構邊界日期,以及查詢驅動程式如何呈現這些日期;使邊界不受本地時區影響,並斷言傳遞給驅動程式的值。兩個時區下的 17 個 specs 全部通過後即完成。
由索引模型根據 Issue 內容生成。
描述
test/unit/repositories/user-subscription-repository.spec.ts passes under TZ=UTC and fails under any negative-offset zone, so the pre-commit hook cannot pass for anyone running outside UTC — including this development environment, which is America/Toronto.
$ TZ=UTC npx mocha test/unit/repositories/user-subscription-repository.spec.ts
17 passing
$ TZ=America/Toronto npx mocha test/unit/repositories/user-subscription-repository.spec.ts
12 passing, 5 failing
AssertionError: expected 'select * from "user_subscriptions" wh…' to include '"current_period_end" <= '2026-01-31'
All five are the same defect: the specs build a boundary date and assert the literal 2026-01-31 appears in the generated SQL, but the driver renders the value in the local zone, so at UTC-5 the SQL carries a different instant. The two updateIfCurrent failures are the same cause in the IS NOT DISTINCT FROM clause.
CI is UTC, so main is green and the problem is invisible there. It only appears locally, as a pre-commit failure that looks like the change under test is broken.
Fix direction: make the boundary explicit rather than ambient — construct the dates in UTC (or set process.env.TZ = 'UTC' before the module under test is imported, which Node honours for later Date work) and assert on the value the driver is given, not on a date literal that only matches in UTC.
Found while committing an unrelated compose fix (#929).
- 主要語言
- TypeScript
- 星號
- 829
- 分支
- 234
- 平均合併
- 17 小時 6 分鐘
- 30 天內合併 PR
- 92
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
cameri/nostream 的其他 Issue
-
factory rewrite rust
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
factory rewrite rust
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 70/100
microsoft/playwright#43640 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
grasshopper-protocol/grsshppr#172 ·
維護者通常 1 天內回覆
-
bug help wanted
難度 2/5 1-3 小時 新手友好度 78/100
Tencent/teamai-cli#1397 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
DouyinFE/semi-design#3641 ·
維護者通常 3 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆