forked from jmgilman/consulrs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.rs
53 lines (44 loc) · 1.57 KB
/
service.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
mod common;
use common::{ConsulServer, ConsulServerHelper, CountingServer};
use consulrs::{client::Client, service};
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();
let service = common::setup(&client, &counting).await;
test_register(&client, "test").await;
test_list(&client).await;
test_read(&client, &service.name).await;
test_health(&client, &service.name).await;
test_maintenance(&client, &service.name).await;
test_deregister(&client, &service.name).await;
});
}
async fn test_deregister(client: &impl Client, name: &str) {
let res = service::deregister(client, name, None).await;
assert!(res.is_ok());
}
async fn test_health(client: &impl Client, name: &str) {
let res = service::health(client, name, None).await;
assert!(res.is_ok());
}
async fn test_list(client: &impl Client) {
let res = service::list(client, None).await;
assert!(res.is_ok());
}
async fn test_maintenance(client: &impl Client, name: &str) {
let res = service::maintenance(client, name, true, None).await;
assert!(res.is_ok());
}
async fn test_register(client: &impl Client, name: &str) {
let res = service::register(client, name, None).await;
assert!(res.is_ok());
}
async fn test_read(client: &impl Client, name: &str) {
let res = service::read(client, name, None).await;
assert!(res.is_ok());
}