cover lib async clear shutdown

This commit is contained in:
Nanaloveyuki
2026-06-14 06:35:14 +08:00
parent e91aba10fc
commit 6962c7f267
+26
View File
@@ -1172,6 +1172,32 @@ async test "library async builder unwrap matches direct async builder behavior"
inspect(full.last_error() == direct.last_error(), content="true")
}
async test "library async builder shutdown clear abandons pending records through facade" {
let logger = build_library_async_logger(
AsyncLoggerBuildConfig::new(
logger=@bitlogger.LoggerConfig::new(
min_level=@bitlogger.Level::Info,
target="async.lib.builder.clear",
sink=@bitlogger.SinkConfig::new(kind=@bitlogger.SinkKind::Console),
),
async_config=AsyncLoggerConfig::new(
max_pending=2,
overflow=AsyncOverflowPolicy::Blocking,
),
),
)
let full = logger.to_async_logger()
logger.info("one")
inspect(full.pending_count(), content="1")
inspect(full.dropped_count(), content="0")
logger.shutdown(clear=true)
inspect(full.is_closed(), content="true")
inspect(full.is_running(), content="false")
inspect(full.pending_count(), content="0")
inspect(full.dropped_count(), content="1")
}
async test "parsed library async logger unwrap keeps async helper surface" {
let logger = parse_and_build_library_async_logger(
"{\"logger\":{\"min_level\":\"warn\",\"target\":\"async.lib.config.helpers\",\"sink\":{\"kind\":\"console\"}},\"async_config\":{\"max_pending\":2,\"overflow\":\"DropOldest\",\"max_batch\":1,\"linger_ms\":0,\"flush\":\"Shutdown\"}}",