Source commit: ffc6f14a3723ea6aa513613a5406d737f21b201d Public tree identity: sha256:a77575c31dda8de868bc8de91d94df55c46f0b028e755e56a8cce8e27f72a42b
37 lines
1.2 KiB
Rust
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"));
|
|
}
|