clusterflux-public/crates/clusterflux-sdk/tests/product_api.rs
Clusterflux release f8bf4e94cc Public release release-b215a8f6e506
Source commit: b215a8f6e506fafa38755d1c14e89e5a52c82f9f

Public tree identity: sha256:23ba19e9f6e902cbfb4ed34cd7f9e1aaa39945e9b61946b879d7254b3f033502
2026-07-19 14:57:40 +02:00

37 lines
1.2 KiB
Rust

#[clusterflux::task]
async fn plus_one(value: i32) -> clusterflux::Result<i32> {
Ok(value + 1)
}
#[test]
fn unified_spawn_defaults_to_function_identity_and_unwraps_task_result() {
futures_executor::block_on(async {
let handle = clusterflux::spawn!(plus_one(41))
.on(clusterflux::env!("linux"))
.await
.unwrap();
assert_eq!(handle.name(), "plus_one");
assert_eq!(handle.env().unwrap().name, "linux");
assert_eq!(handle.join().await.unwrap(), 42);
});
}
#[test]
fn source_mount_and_command_failure_are_public_typed_contracts() {
let source = clusterflux::SourceSnapshot {
digest: "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
.to_owned(),
};
assert_eq!(source.mount().unwrap(), "/workspace");
let error = clusterflux::Error::CommandFailed {
program: "cc".to_owned(),
status_code: Some(2),
stdout: "out".to_owned(),
stderr: "bad input".to_owned(),
stdout_truncated: false,
stderr_truncated: false,
};
assert!(error.to_string().contains("command"));
assert!(error.to_string().contains("cc"));
}