mirror of https://github.com/chipsenkbeil/distant
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
Rust
34 lines
1.0 KiB
Rust
use crate::cli::fixtures::*;
|
|
use distant_core::data::{Capabilities, Capability};
|
|
use rstest::*;
|
|
use serde_json::json;
|
|
|
|
#[rstest]
|
|
#[tokio::test]
|
|
async fn should_support_json_capabilities(mut json_repl: CtxCommand<Repl>) {
|
|
let id = rand::random::<u64>().to_string();
|
|
let req = json!({
|
|
"id": id,
|
|
"payload": { "type": "capabilities" },
|
|
});
|
|
|
|
let res = json_repl.write_and_read_json(req).await.unwrap().unwrap();
|
|
|
|
assert_eq!(res["origin_id"], id);
|
|
assert_eq!(res["payload"]["type"], "capabilities");
|
|
|
|
let supported: Capabilities = res["payload"]["supported"]
|
|
.as_array()
|
|
.expect("Field 'supported' was not an array")
|
|
.iter()
|
|
.map(|value| {
|
|
serde_json::from_value::<Capability>(value.clone())
|
|
.expect("Could not read array value as capability")
|
|
})
|
|
.collect();
|
|
|
|
// NOTE: Our local server api should always support all capabilities since it is the reference
|
|
// implementation for our api
|
|
assert_eq!(supported, Capabilities::all());
|
|
}
|