mcp: tests for the settings beside the books, year earnings (open periods, last year's partial close), year 1, a failed flush; drop by-class P&L's dead placeholder guard; record config, MCP, GUI mutation scores
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX
This commit is contained in:
1 parent
ca3a279219
commit
efa370dfa3
4 files changed
+112
-5
No files matched your search
@@ -194,4 +194,43 @@ mod tests {
|
||||
);
|
||||
assert_eq!(classify(" "), Line::Skip);
|
||||
}
|
||||
|
||||
/// Counts the lines written to it; every flush fails.
|
||||
struct FailingFlush(std::sync::Arc<std::sync::atomic::AtomicUsize>);
|
||||
|
||||
impl AsyncWrite for FailingFlush {
|
||||
fn poll_write(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_: &mut std::task::Context<'_>,
|
||||
buf: &[u8],
|
||||
) -> std::task::Poll<std::io::Result<usize>> {
|
||||
let lines = buf.iter().filter(|&&b| b == b'\n').count();
|
||||
self.0.fetch_add(lines, std::sync::atomic::Ordering::SeqCst);
|
||||
std::task::Poll::Ready(Ok(buf.len()))
|
||||
}
|
||||
fn poll_flush(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<std::io::Result<()>> {
|
||||
std::task::Poll::Ready(Err(std::io::Error::other("closed")))
|
||||
}
|
||||
fn poll_shutdown(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<std::io::Result<()>> {
|
||||
std::task::Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
/// A client that can't take a flushed reply is gone: the writer stops
|
||||
/// after the first, rather than writing on into a dead channel.
|
||||
#[tokio::test]
|
||||
async fn a_failed_flush_stops_the_writer() {
|
||||
let written = std::sync::Arc::new(std::sync::atomic::AtomicUsize::new(0));
|
||||
let input = std::io::Cursor::new(b"not json\nnor this\n".to_vec());
|
||||
let (rmcp_in, rmcp_out, writer) = spawn(input, FailingFlush(written.clone()));
|
||||
drop((rmcp_in, rmcp_out));
|
||||
writer.await.unwrap();
|
||||
assert_eq!(written.load(std::sync::atomic::Ordering::SeqCst), 1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user