mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 01:01:00 +00:00
update test
This commit is contained in:
committed by
Quentin de Quelen
parent
6016f2e941
commit
81ce90e57f
@ -1,4 +1,3 @@
|
||||
use http_service::Body;
|
||||
use serde_json::json;
|
||||
use std::convert::Into;
|
||||
|
||||
@ -6,51 +5,34 @@ mod common;
|
||||
|
||||
#[test]
|
||||
fn test_healthyness() {
|
||||
let mut server = common::setup_server().unwrap();
|
||||
let mut server = common::Server::with_uid("movies");
|
||||
|
||||
// Check that the server is healthy
|
||||
|
||||
let req = http::Request::get("/health").body(Body::empty()).unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 200);
|
||||
let (_response, status_code) = server.get_health();
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
// Set the serve Unhealthy
|
||||
|
||||
let body = json!({
|
||||
"health": false,
|
||||
})
|
||||
.to_string()
|
||||
.into_bytes();
|
||||
|
||||
let req = http::Request::put("/health")
|
||||
.body(Body::from(body))
|
||||
.unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 200);
|
||||
});
|
||||
let (_response, status_code) = server.update_health(body);
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
// Check that the server is unhealthy
|
||||
|
||||
let req = http::Request::get("/health").body(Body::empty()).unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 503);
|
||||
let (_response, status_code) = server.get_health();
|
||||
assert_eq!(status_code, 503);
|
||||
|
||||
// Set the server healthy
|
||||
|
||||
let body = json!({
|
||||
"health": true,
|
||||
})
|
||||
.to_string()
|
||||
.into_bytes();
|
||||
|
||||
let req = http::Request::put("/health")
|
||||
.body(Body::from(body))
|
||||
.unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 200);
|
||||
});
|
||||
let (_response, status_code) = server.update_health(body);
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
// Check if the server is healthy
|
||||
|
||||
let req = http::Request::get("/health").body(Body::empty()).unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 200);
|
||||
let (_response, status_code) = server.get_health();
|
||||
assert_eq!(status_code, 200);
|
||||
}
|
||||
|
Reference in New Issue
Block a user