diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 16472807..d416a644 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -22,11 +22,15 @@ Code coverage stats are generated automatically in CI. To generate coverage stat # Install coverage dependencies cargo binstall grcov rustup component add llvm-tools +# If you have Nix on you system, you can install the `genhtml` command using the nix package. +# Todo: other methods of installing `genhtml` +nix-env -iA nixpkgs.lcov # Build + run tests with coverage -cargo llvm-cov --no-report nextest --all-features +cargo llvm-cov --no-report nextest --all-features # Generate and open an HTML coverage report -grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/ -open target/debug/coverage/index.html +cargo llvm-cov report --lcov --output-path ./target/llvm-cov-target/debug/lcov.info +genhtml -o ./target/llvm-cov-target/debug/coverage/ --show-details --highlight --ignore-errors source --legend ./target/llvm-cov-target/debug/lcov.info +open target/llvm-cov-target/debug/coverage/index.html ``` # Releases diff --git a/src/util/serde_util.rs b/src/util/serde_util.rs index 95b41cad..20aaa305 100644 --- a/src/util/serde_util.rs +++ b/src/util/serde_util.rs @@ -56,7 +56,7 @@ pub fn default_true() -> bool { #[cfg(test)] mod tests { - use crate::util::serde_util::UriOrString; + use super::*; use serde_derive::{Deserialize, Serialize}; use serde_json::from_str; use std::str::FromStr; @@ -85,9 +85,26 @@ mod tests { assert_eq!(s, r#"{"inner":"https://example.com/"}"#); } + #[test] + fn uri_or_string_uri_variant_to_string() { + let uri = UriOrString::Uri(Url::from_str("https://example.com").unwrap()); + assert_eq!("https://example.com/", uri.to_string()); + } + + #[test] + fn uri_or_string_string_variant_to_string() { + let uri = UriOrString::String("foo".to_string()); + assert_eq!("foo", uri.to_string()); + } + #[test] fn deserialize_uri_or_string_as_string() { let value: Wrapper = from_str(r#"{"inner": "invalid-uri"}"#).unwrap(); assert_eq!(value.inner, UriOrString::String("invalid-uri".to_string())); } + + #[test] + fn default_true_returns_true() { + assert!(default_true()); + } }