Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
use super::{health, mount_at_root_and_prefix, swagger_ui};
use axum::{
Router,
body::Body,
http::{Request, StatusCode},
routing::get,
};
use tower::ServiceExt;
async fn ok() -> &'static str {
"ok"
}
fn sample_app() -> Router {
mount_at_root_and_prefix(
Router::new()
.route("/health", get(ok))
.route("/email/messages", get(ok))
.route("/gmail/webhook", get(ok))
.route("/internal/ping", get(ok)),
)
}
async fn get_status(app: Router, path: &str) -> StatusCode {
app.oneshot(
Request::builder()
.uri(path)
.method("GET")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap()
.status()
}
#[tokio::test]
async fn health_is_reachable_at_root_and_gateway_prefix() {
for path in ["/health", "/email/health"] {
let response = mount_at_root_and_prefix(health::router())
.oneshot(
Request::builder()
.uri(path)
.method("GET")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK, "{path}");
}
}
#[tokio::test]
async fn existing_paths_stay_and_are_also_served_under_the_prefix() {
for path in [
"/health",
"/email/health",
"/email/messages",
"/email/email/messages",
"/gmail/webhook",
"/email/gmail/webhook",
"/internal/ping",
"/email/internal/ping",
] {
assert_eq!(
get_status(sample_app(), path).await,
StatusCode::OK,
"{path}"
);
}
}
#[tokio::test]
async fn unprefixed_unknown_path_is_not_rewritten_onto_the_prefix() {
let response = mount_at_root_and_prefix(health::router())
.oneshot(
Request::builder()
.uri("/missing")
.method("GET")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::NOT_FOUND);
}
#[tokio::test]
async fn openapi_is_served_at_root_and_gateway_prefix() {
let api = swagger_ui();
for uri in ["/api-doc/openapi.json", "/email/api-doc/openapi.json"] {
let response = api
.clone()
.oneshot(
Request::builder()
.uri(uri)
.method("GET")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK, "{uri}");
}
}