forked from jmgilman/consulrs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.rs
65 lines (55 loc) · 1.84 KB
/
check.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
mod common;
use common::{ConsulServer, ConsulServerHelper, CountingServer};
use consulrs::{api::check::requests::RegisterCheckRequest, check, client::Client};
use test_log::test;
#[test]
fn test() {
let test = common::new_test();
test.run(|instance| async move {
let server: ConsulServer = instance.server();
let counting: CountingServer = instance.server();
let client = server.client();
common::setup(&client, &counting).await;
let name = "test";
test_register(&client, name).await;
test_list(&client).await;
test_fail(&client, name).await;
test_pass(&client, name).await;
test_warn(&client, name).await;
test_set_status(&client, name, "critical").await;
test_deregister(&client, name).await;
});
}
async fn test_deregister(client: &impl Client, name: &str) {
let res = check::deregister(client, name, None).await;
assert!(res.is_ok());
}
async fn test_fail(client: &impl Client, name: &str) {
let res = check::fail(client, name, None).await;
assert!(res.is_ok());
}
async fn test_list(client: &impl Client) {
let res = check::list(client, None).await;
assert!(res.is_ok());
}
async fn test_pass(client: &impl Client, name: &str) {
let res = check::pass(client, name, None).await;
assert!(res.is_ok());
}
async fn test_set_status(client: &impl Client, name: &str, status: &str) {
let res = check::set_status(client, name, status, None).await;
assert!(res.is_ok());
}
async fn test_register(client: &impl Client, name: &str) {
let res = check::register(
client,
name,
Some(RegisterCheckRequest::builder().ttl("10m")),
)
.await;
assert!(res.is_ok());
}
async fn test_warn(client: &impl Client, name: &str) {
let res = check::warn(client, name, None).await;
assert!(res.is_ok());
}