增加异步日志和库存展示

This commit is contained in:
yml2213
2026-07-07 08:04:54 +08:00
parent 327b996079
commit 72d59670d4
7 changed files with 313 additions and 20 deletions
+21
View File
@@ -77,3 +77,24 @@ func TestParseStartTimeAcceptsClockOnly(t *testing.T) {
}
})
}
func TestAddLogDoesNotBlockWhenQueueIsFull(t *testing.T) {
app := &App{
logCh: make(chan LogEntry),
logStop: make(chan struct{}),
}
done := make(chan struct{})
go func() {
app.addLog("debug", "test")
close(done)
}()
select {
case <-done:
case <-time.After(100 * time.Millisecond):
t.Fatal("addLog blocked when log queue was full")
}
if dropped := app.droppedLogs.Load(); dropped != 1 {
t.Fatalf("droppedLogs = %d, want 1", dropped)
}
}