-
Notifications
You must be signed in to change notification settings - Fork 40
/
schema_registry_calls.rs
35 lines (31 loc) · 1.23 KB
/
schema_registry_calls.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
use schema_registry_converter::async_impl::schema_registry::{
get_all_subjects, get_all_versions, perform_sr_call, SrSettings,
};
use schema_registry_converter::schema_registry_common::SrCall;
fn get_schema_registry_url() -> String {
String::from("http://localhost:8081")
}
#[tokio::test]
async fn test_get_all_subjects() {
let sr_settings = SrSettings::new(get_schema_registry_url());
let result = get_all_subjects(&sr_settings).await.unwrap();
assert!(
result.contains(&String::from("testavro-value")),
"List of subjects contains testavro-value"
);
}
#[tokio::test]
async fn test_get_versions_for_testavro_value() {
let sr_settings = SrSettings::new(get_schema_registry_url());
let result = get_all_versions(&sr_settings, String::from("testavro-value"))
.await
.unwrap();
assert_eq!(vec![1], result, "List of version is just one");
}
#[tokio::test]
async fn test_get_schema_for_testavro_value() {
let sr_settings = SrSettings::new(get_schema_registry_url());
let sr_call = SrCall::GetBySubjectAndVersion("testavro-value", 1);
let result = perform_sr_call(&sr_settings, sr_call).await.unwrap();
assert_eq!(Some(1), result.version, "Returned schema has version 1");
}