MeiliSearch/meilisearch-http/tests/health.rs

39 lines
915 B
Rust
Raw Normal View History

2020-01-15 17:56:07 +01:00
use serde_json::json;
use std::convert::Into;
mod common;
#[test]
fn test_healthyness() {
2020-03-04 14:18:07 +01:00
let mut server = common::Server::with_uid("movies");
2020-01-15 17:56:07 +01:00
// Check that the server is healthy
2020-03-04 14:18:07 +01:00
let (_response, status_code) = server.get_health();
assert_eq!(status_code, 200);
2020-01-15 17:56:07 +01:00
// Set the serve Unhealthy
let body = json!({
"health": false,
2020-03-04 14:18:07 +01:00
});
let (_response, status_code) = server.update_health(body);
assert_eq!(status_code, 200);
2020-01-15 17:56:07 +01:00
// Check that the server is unhealthy
2020-03-04 14:18:07 +01:00
let (_response, status_code) = server.get_health();
assert_eq!(status_code, 503);
2020-01-15 17:56:07 +01:00
// Set the server healthy
let body = json!({
"health": true,
2020-03-04 14:18:07 +01:00
});
let (_response, status_code) = server.update_health(body);
assert_eq!(status_code, 200);
2020-01-15 17:56:07 +01:00
// Check if the server is healthy
2020-03-04 14:18:07 +01:00
let (_response, status_code) = server.get_health();
assert_eq!(status_code, 200);
2020-01-15 17:56:07 +01:00
}