v0.1.0-pre.011
This commit is contained in:
46
kb-lib/tests/external_executor_api.rs
Normal file
46
kb-lib/tests/external_executor_api.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
// file: kb-lib/tests/external_executor_api.rs
|
||||
// version: 1
|
||||
|
||||
//! Downstream-style compilation contract for externally implemented executors.
|
||||
|
||||
struct ExternalExecutor;
|
||||
|
||||
impl kb_lib::ExApiInstructionExecutor for ExternalExecutor {
|
||||
fn executor_name(&self) -> &'static str {
|
||||
return "external_executor";
|
||||
}
|
||||
|
||||
fn executor_version(&self) -> &'static str {
|
||||
return "1";
|
||||
}
|
||||
|
||||
fn program_ids(&self) -> &'static [&'static str] {
|
||||
return &[];
|
||||
}
|
||||
|
||||
fn supports_request(
|
||||
&self,
|
||||
_request: &kb_lib::ExApiExecutionRequest,
|
||||
) -> kb_lib::ExApiExecutionSupport {
|
||||
return kb_lib::ExApiExecutionSupport::No;
|
||||
}
|
||||
|
||||
fn build_plan(
|
||||
&self,
|
||||
request: &kb_lib::ExApiExecutionRequest,
|
||||
) -> kb_core::Result<kb_lib::ExApiExecutionPlan> {
|
||||
return std::result::Result::Ok(kb_lib::ExApiExecutionPlan {
|
||||
executor_name: self.executor_name().to_string(),
|
||||
instruction_count: 0,
|
||||
payload_json: request.payload_json.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_executor_uses_only_the_public_kb_lib_contract() {
|
||||
let executor: &dyn kb_lib::ExApiInstructionExecutor = &ExternalExecutor;
|
||||
assert_eq!(executor.executor_name(), "external_executor");
|
||||
assert_eq!(executor.executor_version(), "1");
|
||||
assert!(executor.program_ids().is_empty());
|
||||
}
|
||||
Reference in New Issue
Block a user