增加异步日志和库存展示
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user