sql_splitter/redactor/strategy/
skip.rs1use super::{RedactValue, Strategy, StrategyKind};
4
5#[derive(Debug, Clone, Default)]
7pub struct SkipStrategy;
8
9impl SkipStrategy {
10 pub fn new() -> Self {
11 Self
12 }
13}
14
15impl Strategy for SkipStrategy {
16 fn apply(&self, value: &RedactValue, _rng: &mut dyn rand::RngCore) -> RedactValue {
17 value.clone()
19 }
20
21 fn kind(&self) -> StrategyKind {
22 StrategyKind::Skip
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29 use rand::SeedableRng;
30
31 #[test]
32 fn test_skip_strategy() {
33 let strategy = SkipStrategy::new();
34 let mut rng = rand::rngs::StdRng::seed_from_u64(42);
35
36 let result = strategy.apply(&RedactValue::String("test".to_string()), &mut rng);
38 match result {
39 RedactValue::String(s) => assert_eq!(s, "test"),
40 _ => panic!("Expected String"),
41 }
42
43 let result = strategy.apply(&RedactValue::Integer(123), &mut rng);
45 match result {
46 RedactValue::Integer(i) => assert_eq!(i, 123),
47 _ => panic!("Expected Integer"),
48 }
49
50 let result = strategy.apply(&RedactValue::Null, &mut rng);
52 assert!(matches!(result, RedactValue::Null));
53 }
54}