fix(trading_engine): tolerate AlreadyReg in metrics initialization test
Prometheus registry.register() returns AlreadyReg when another test thread triggers the lazy_static counters first. Both Ok and AlreadyReg are valid — only hard errors indicate a real problem. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1311,7 +1311,18 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_metrics_initialization() {
|
||||
assert!(initialize_metrics().is_ok());
|
||||
// initialize_metrics() returns AlreadyReg if another test in this
|
||||
// process already triggered the lazy_static counters. Both Ok and
|
||||
// AlreadyReg are acceptable — only a hard error would be a bug.
|
||||
let result = initialize_metrics();
|
||||
assert!(
|
||||
result.is_ok()
|
||||
|| result
|
||||
.as_ref()
|
||||
.err()
|
||||
.map_or(false, |e| format!("{e}").contains("already")),
|
||||
"initialize_metrics failed with unexpected error: {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user