Download codex-rs/core/tests/common/startup_tests.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/core/tests/common/startup_tests.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/core/tests/common/startup_tests.rs
-
curl -L -o startup_tests.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/core/tests/common/startup_tests.rs
1.43 kB
| //! Keeps startup failures visible even when downstream mocks have unmet expectations. | |
| use super::expect_startup; | |
| use crate::responses::ev_completed; | |
| use crate::responses::mount_sse_sequence; | |
| use crate::responses::sse; | |
| use crate::responses::start_mock_server; | |
| use anyhow::Result; | |
| use anyhow::anyhow; | |
| use pretty_assertions::assert_eq; | |
| use std::future::pending; | |
| use std::future::ready; | |
| use std::time::Duration; | |
| use tokio::time::sleep; | |
| async fn startup_can_complete_after_five_seconds() { | |
| let value = expect_startup(async { | |
| sleep(Duration::from_secs(/*secs*/ 6)).await; | |
| Ok("ready") | |
| }) | |
| .await; | |
| assert_eq!(value, "ready"); | |
| } | |
| async fn startup_timeout_is_not_masked_by_mock_expectations() { | |
| let server = start_mock_server().await; | |
| mount_sse_sequence(&server, vec![sse(vec![ev_completed("unused")])]).await; | |
| expect_startup(pending::<Result<()>>()).await; | |
| } | |
| async fn startup_error_is_not_masked_by_mock_expectations() { | |
| let server = start_mock_server().await; | |
| mount_sse_sequence(&server, vec![sse(vec![ev_completed("unused")])]).await; | |
| let startup: Result<()> = Err(anyhow!("injected startup failure")); | |
| expect_startup(ready(startup)).await; | |
| } | |