From 82743704e428fb5638174ca09fba87c029853210 Mon Sep 17 00:00:00 2001 From: longgexx Date: Thu, 15 Jan 2026 11:42:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(test):=20=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=BE=85=E5=8A=A9=E5=87=BD=E6=95=B0=20truncateToDayUT?= =?UTF-8?q?C=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 usage_log_repo_integration_test.go 中添加本地的 truncateToDayUTC 辅助函数,修复因主代码重命名该函数导致的测试编译错误。 Co-Authored-By: Claude Opus 4.5 --- .../internal/repository/usage_log_repo_integration_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/internal/repository/usage_log_repo_integration_test.go b/backend/internal/repository/usage_log_repo_integration_test.go index c9c2678b..3b48fbb9 100644 --- a/backend/internal/repository/usage_log_repo_integration_test.go +++ b/backend/internal/repository/usage_log_repo_integration_test.go @@ -36,6 +36,12 @@ func TestUsageLogRepoSuite(t *testing.T) { suite.Run(t, new(UsageLogRepoSuite)) } +// truncateToDayUTC 截断到 UTC 日期边界(测试辅助函数) +func truncateToDayUTC(t time.Time) time.Time { + t = t.UTC() + return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC) +} + func (s *UsageLogRepoSuite) createUsageLog(user *service.User, apiKey *service.APIKey, account *service.Account, inputTokens, outputTokens int, cost float64, createdAt time.Time) *service.UsageLog { log := &service.UsageLog{ UserID: user.ID,