Add terminal service implementation and integration tests
- Introduced terminal.h header file defining the terminal service API. - Implemented integration tests for terminal service registration and health checks. - Added unit tests for FFI layer, health checks, and terminal service functionality. - Created a mock center for testing terminal registration and deregistration. - Ensured proper error handling and response validation in tests.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
use buffa::MessageField;
|
||||
use buffa_types::google::protobuf::{Any, StringValue};
|
||||
use proto::proto::control::{InvokeResponse, TerminalEventHandle};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct TerminalError {
|
||||
pub(crate) code: &'static str,
|
||||
pub(crate) message: String,
|
||||
}
|
||||
|
||||
impl TerminalError {
|
||||
pub(crate) fn new(code: &'static str, message: impl Into<String>) -> Self {
|
||||
Self {
|
||||
code,
|
||||
message: message.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn into_response(self) -> InvokeResponse {
|
||||
let error = StringValue {
|
||||
value: format!("{}: {}", self.code, self.message),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
InvokeResponse {
|
||||
success: false,
|
||||
message: MessageField::some(Any::pack(&error, StringValue::TYPE_URL)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn display_message(&self) -> String {
|
||||
format!("{}: {}", self.code, self.message)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn success_handle(handle: &TerminalEventHandle) -> InvokeResponse {
|
||||
InvokeResponse {
|
||||
success: true,
|
||||
message: MessageField::some(Any::pack(handle, TerminalEventHandle::TYPE_URL)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user