mod common;
#[tokio::test(flavor = "multi_thread")]
async fn list_runs() {
let client = require_client!();
let page = client
.runs()
.list(Default::default(), Default::default())
.await
.expect("listing runs should succeed");
assert!(page.total >= 0);
}
#[tokio::test(flavor = "multi_thread")]
async fn run_actor_and_read_outputs() {
let client = require_client!();
let run = client
.actor("apify/hello-world")
.call::<serde_json::Value>(None, Default::default(), Some(120))
.await
.expect("call hello-world actor");
assert_eq!(
run.status.as_deref(),
Some("SUCCEEDED"),
"hello-world run should succeed"
);
let fetched = client
.run(&run.id)
.get()
.await
.expect("get run")
.expect("run should exist");
assert_eq!(fetched.id, run.id);
let log = client.run(&run.id).log().get().await.expect("get run log");
assert!(log.is_some(), "finished run should have a log");
let raw_log = client
.run(&run.id)
.log()
.get_with_options(apify_client::LogOptions { raw: Some(true) })
.await
.expect("get raw run log");
assert!(raw_log.is_some(), "finished run should have a raw log");
let _items = client
.run(&run.id)
.dataset()
.list_items::<serde_json::Value>(Default::default())
.await
.expect("read run dataset");
let output = client
.run(&run.id)
.key_value_store()
.get_record("OUTPUT")
.await
.expect("read OUTPUT record");
assert!(
output.is_some(),
"hello-world should produce an OUTPUT record"
);
}
#[tokio::test(flavor = "multi_thread")]
async fn last_run_access() {
let client = require_client!();
client
.actor("apify/hello-world")
.call::<serde_json::Value>(None, Default::default(), Some(120))
.await
.expect("call hello-world actor");
let last = client
.actor("apify/hello-world")
.last_run(Some("SUCCEEDED"))
.get()
.await
.expect("get last run");
assert!(last.is_some(), "there should be a last succeeded run");
}