Source commit: b8454b34d38cc2ba0bd278e842060db45d091e1c Public tree identity: sha256:69d6c8143bf6227e1bb07852aa94e8af9c26793eca252bb46788894f728cb6d2
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"));
|
|
}
|