The tally remembers why the page went down; until a load succeeds, render() ends each new request with that reason instead of calling a dead page. end_renders is a free function with a gpui test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
657 B
Rust
19 lines
657 B
Rust
use std::{cell::RefCell, rc::Rc};
|
|
|
|
use serde_json::Value;
|
|
|
|
#[gpui::test]
|
|
fn each_owed_render_ends_once_with_the_reason(cx: &mut gpui::TestAppContext) {
|
|
let got = Rc::new(RefCell::new(Vec::<(u8, Result<Value, String>)>::new()));
|
|
let pending = (0..2)
|
|
.map(|n| {
|
|
let got = got.clone();
|
|
Box::new(move |rendered, _: &mut gpui::App| got.borrow_mut().push((n, rendered))) as super::Rendered
|
|
})
|
|
.collect();
|
|
cx.update(|cx| super::end_renders(pending, "denied", cx));
|
|
cx.run_until_parked();
|
|
let denied = || Err("denied".to_string());
|
|
assert_eq!(*got.borrow(), [(0, denied()), (1, denied())]);
|
|
}
|