Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
cargo-binstall --no-confirm cargo-tarpaulin

- name: Run the tests
run: cargo tarpaulin --out xml -- --nocapture
run: cargo tarpaulin --all --doc --out xml -- --nocapture

- name: Generate and validate the OpenAPI specification
run: |
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-lib/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
//! async fn print_status(http_url: url::Url, ws_url: url::Url, token: AuthToken) -> anyhow::Result<()> {
//! let http_client = BaseHTTPClient::new(http_url)?
//! .authenticated(&token)?;
//! let ws_client = WebSocketClient::connect(&ws_url, token.clone(), false)
//! let ws_client = WebSocketClient::connect(&ws_url, &token, false)
//! .await?;
//! let monitor = Monitor::connect(http_client, ws_client).await.unwrap();
//! let mut updates = monitor.subscribe();
Expand Down
15 changes: 9 additions & 6 deletions rust/agama-lib/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,23 @@ impl std::fmt::Display for ValidationOutcome {
/// ```
/// # use agama_lib::profile::{ProfileValidator, ValidationOutcome};
/// # use std::path::Path;
/// let validator = ProfileValidator::new(
/// Path::new("share/profile.schema.json")
/// ).expect("the default validator");
/// let path = Path::new(env!("CARGO_MANIFEST_DIR"))
/// .join("share/profile.schema.json");
/// let validator = ProfileValidator::new(&path)
/// .expect("the default validator");
///
/// // you can validate a &str
/// let wrong_profile = r#"
/// { "product": { "name": "Tumbleweed" } }
/// "#;
/// let result = validator.validate_str(&wrong_profile).unwrap();
/// assert!(matches!(ValidationOutcome::NotValid, result));
/// assert!(matches!(result, ValidationOutcome::NotValid(_)));
///
/// // or a file
/// validator.validate_file(Path::new("share/examples/profile.json"));
/// assert!(matches!(ValidationOutcome::Valid, result));
/// let path = Path::new(env!("CARGO_MANIFEST_DIR"))
/// .join("share/examples/profile_tw.json");
/// let result = validator.validate_file(&path).unwrap();
/// assert!(matches!(result, ValidationOutcome::Valid));
/// ```
pub struct ProfileValidator {
validator: jsonschema::Validator,
Expand Down
Loading