Skip to content

Commit

Permalink
test: print RPC method with no regression test snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Mar 6, 2025
1 parent 106c2f2 commit 4203d60
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/tool/subcommands/api_cmd/test_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ async fn ctx(
mod tests {
use super::*;
use crate::utils::net::{download_file_with_cache, DownloadFileOption};
use ahash::HashSet;
use directories::ProjectDirs;
use futures::{stream::FuturesUnordered, StreamExt};
use itertools::Itertools as _;
Expand Down Expand Up @@ -220,4 +221,33 @@ mod tests {
println!(" succeeded.");
}
}

#[test]
fn rpc_regression_tests_print_uncovered() {
let pattern = lazy_regex::regex!(r#"^(?P<name>filecoin_.+)_\d+\.rpcsnap\.json\.zst$"#);
let covered = HashSet::from_iter(
include_str!("test_snapshots.txt")
.trim()
.split("\n")
.map(|i| {
let captures = pattern.captures(i).expect("pattern capture failure");
captures
.name("name")
.expect("no named capture group")
.as_str()
.replace("_", ".")
.to_lowercase()
}),
);
macro_rules! print_uncovered {
($ty:ty) => {
let name = <$ty>::NAME.to_lowercase();
if !covered.contains(&name) {
println!("{} is uncovered.", <$ty>::NAME);
}
};
}

crate::for_each_rpc_method!(print_uncovered);
}
}

0 comments on commit 4203d60

Please sign in to comment.