#[clusterflux::task] async fn plus_one(value: i32) -> clusterflux::Result { 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")); }