mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-06 12:46:31 +00:00
Test cli behavior
This commit is contained in:
@ -182,6 +182,10 @@ impl Server<Owned> {
|
|||||||
self.service.patch("/network", value).await
|
self.service.patch("/network", value).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn set_webhooks(&self, value: Value) -> (Value, StatusCode) {
|
||||||
|
self.service.patch("/webhooks", value).await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_metrics(&self) -> (Value, StatusCode) {
|
pub async fn get_metrics(&self) -> (Value, StatusCode) {
|
||||||
self.service.get("/metrics").await
|
self.service.get("/metrics").await
|
||||||
}
|
}
|
||||||
@ -447,6 +451,10 @@ impl<State> Server<State> {
|
|||||||
pub async fn get_network(&self) -> (Value, StatusCode) {
|
pub async fn get_network(&self) -> (Value, StatusCode) {
|
||||||
self.service.get("/network").await
|
self.service.get("/network").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_webhooks(&self) -> (Value, StatusCode) {
|
||||||
|
self.service.get("/webhooks").await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_settings(dir: impl AsRef<Path>) -> Opt {
|
pub fn default_settings(dir: impl AsRef<Path>) -> Opt {
|
||||||
|
@ -68,12 +68,13 @@ async fn create_webhook_server() -> WebhookHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web::test]
|
#[actix_web::test]
|
||||||
async fn test_basic_webhook() {
|
async fn test_cli_webhook() {
|
||||||
let WebhookHandle { server_handle, url, mut receiver } = create_webhook_server().await;
|
let WebhookHandle { server_handle, url, mut receiver } = create_webhook_server().await;
|
||||||
|
|
||||||
let db_path = tempfile::tempdir().unwrap();
|
let db_path = tempfile::tempdir().unwrap();
|
||||||
let server = Server::new_with_options(Opt {
|
let server = Server::new_with_options(Opt {
|
||||||
task_webhook_url: Some(Url::parse(&url).unwrap()),
|
task_webhook_url: Some(Url::parse(&url).unwrap()),
|
||||||
|
task_webhook_authorization_header: Some(String::from("Bearer a-secret-token")),
|
||||||
..default_settings(db_path.path())
|
..default_settings(db_path.path())
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@ -125,5 +126,20 @@ async fn test_basic_webhook() {
|
|||||||
|
|
||||||
assert!(nb_tasks == 5, "We should have received the 5 tasks but only received {nb_tasks}");
|
assert!(nb_tasks == 5, "We should have received the 5 tasks but only received {nb_tasks}");
|
||||||
|
|
||||||
|
let (webhooks, code) = server.get_webhooks().await;
|
||||||
|
snapshot!(code, @"200 OK");
|
||||||
|
snapshot!(webhooks, @r#"
|
||||||
|
{
|
||||||
|
"webhooks": {
|
||||||
|
"_cli": {
|
||||||
|
"url": "http://127.0.0.1:51503/",
|
||||||
|
"headers": {
|
||||||
|
"Authorization": "Bearer a-secret-token"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#);
|
||||||
|
|
||||||
server_handle.abort();
|
server_handle.abort();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user