From 7c9b27f3a1990a17f7ba4b6503346313ddacd350 Mon Sep 17 00:00:00 2001 From: xuans Date: Tue, 1 Sep 2026 00:36:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=97=A5=E5=BF=97=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E6=B5=8B=E8=AF=95=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/logging/logging_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/internal/logging/logging_test.go b/backend/internal/logging/logging_test.go index 9af23b2..91b97bf 100644 --- a/backend/internal/logging/logging_test.go +++ b/backend/internal/logging/logging_test.go @@ -113,7 +113,8 @@ func TestDailyFileWriterRejectsSymlink(t *testing.T) { func TestDailyFileWriterKeepsDailyCapAfterRestart(t *testing.T) { directory := t.TempDir() - now := time.Date(2026, 8, 31, 8, 0, 0, 0, time.Local) + now := time.Now() + activePath := filepath.Join(directory, "scert.log") writer, err := newDailyFileWriterWithOptions(directory, 16, 30, func() time.Time { return now }) if err != nil { t.Fatalf("初始化日志轮转器失败:%v", err) @@ -136,14 +137,14 @@ func TestDailyFileWriterKeepsDailyCapAfterRestart(t *testing.T) { t.Fatalf("再次关闭日志轮转器失败:%v", err) } - info, err := os.Stat(filepath.Join(directory, "scert.log")) + info, err := os.Stat(activePath) if err != nil { t.Fatalf("读取活动日志状态失败:%v", err) } if info.Size() != 16 { t.Fatalf("服务重启后每日日志容量被绕过:%d", info.Size()) } - if _, err := os.Stat(filepath.Join(directory, "scert-20260831.log")); !os.IsNotExist(err) { + if _, err := os.Stat(filepath.Join(directory, "scert-"+logDay(now)+".log")); !os.IsNotExist(err) { t.Fatalf("同日重启不应轮转活动日志:%v", err) } }