Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(channels): mock telegram sendMessage and sendChatAction endpoints

Steven Enamakel2832a4b55738
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rs
index ab1b23edc8..480a689034 100644
--- a/crates/openhuman-core/src/channels/runtime/test_support.rs
+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs
@@ -24,7 +24,7 @@ use tinychannels_bus::{ChannelMessage, SendMessage};
use tinychannels_runtime::Channel;
use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};
use tinytools::{Tool, ToolResult};
-use wiremock::matchers::method;
+use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
#[derive(Debug, Clone)]
@@ -168,12 +168,26 @@ impl LinkedTelegramRuntime {
pub(crate) async fn linked_telegram_runtime() -> LinkedTelegramRuntime {
let server = MockServer::start().await;
Mock::given(method("POST"))
+ .and(path("/bottoken/sendChatAction"))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
"ok": true,
"result": true
})))
.mount(&server)
.await;
+ Mock::given(method("POST"))
+ .and(path("/bottoken/sendMessage"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
+ "ok": true,
+ "result": {
+ "message_id": 991,
+ "date": 1,
+ "chat": { "id": 42, "type": "private" },
+ "text": "dispatch ok"
+ }
+ })))
+ .mount(&server)
+ .await;
let env = crate::config::test_env::EnvVarGuard::locked_async()
.await
.with("OPENHUMAN_TELEGRAM_BOT_API_BASE", server.uri());