clusterflux-public/crates/clusterflux-sdk/tests/product_api.rs
Clusterflux release eb1077f380 Public release release-09ca780bd67a
Source commit: 09ca780bd67a00467e78139cf38466b8201b66ca

Public tree identity: sha256:2f744c260b5fc2cf074ad9129f97f87f03714902e5b9fe174128afdc342ec2d0
2026-07-19 18:38: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"));
}