use super::*;
#[test]
fn validates_pull_options() {
let (cache, _directory) = test_cache();
let registry = Registry::new()
.register(RegisteredFlow)
.expect("register Flow");
for options in [
WorkerOptions::new().pull(
PullWorkerOptions::new()
.max_concurrent_tasks(2)
.reserved_rpc_tasks(2),
),
WorkerOptions::new().pull(
PullWorkerOptions::new()
.max_concurrent_tasks(2)
.reserved_rpc_tasks(3),
),
WorkerOptions::new().pull(PullWorkerOptions::new().stop_drain_timeout(Duration::ZERO)),
WorkerOptions::new().pull(PullWorkerOptions::new().app_worker_id("bad/id")),
WorkerOptions::new().pull(PullWorkerOptions::new().app_worker_id("RegisteredFlow")),
] {
assert!(matches!(
Worker::try_new(registry.clone(), Arc::clone(&cache), options),
Err(SdkError::FlowDefinition { .. })
));
}
let zero_capacity_error = Worker::try_new(
registry.clone(),
Arc::clone(&cache),
WorkerOptions::new().pull(PullWorkerOptions::new().max_concurrent_tasks(0)),
)
.err()
.expect("zero task capacity must fail");
assert!(
zero_capacity_error
.to_string()
.contains("pull Worker task limit and drain timeout must be positive")
);
assert!(
Worker::try_new(
registry,
cache,
WorkerOptions::new().pull(PullWorkerOptions::new())
)
.is_ok()
);
}