sql_splitter/redactor/strategy/
null.rs1use super::{RedactValue, Strategy, StrategyKind};
4
5#[derive(Debug, Clone, Default)]
7pub struct NullStrategy;
8
9impl NullStrategy {
10 pub fn new() -> Self {
11 Self
12 }
13}
14
15impl Strategy for NullStrategy {
16 fn apply(&self, _value: &RedactValue, _rng: &mut dyn rand::RngCore) -> RedactValue {
17 RedactValue::Null
19 }
20
21 fn kind(&self) -> StrategyKind {
22 StrategyKind::Null
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29 use rand::SeedableRng;
30
31 #[test]
32 fn test_null_strategy() {
33 let strategy = NullStrategy::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 assert!(matches!(result, RedactValue::Null));
39
40 let result = strategy.apply(&RedactValue::Integer(123), &mut rng);
42 assert!(matches!(result, RedactValue::Null));
43
44 let result = strategy.apply(&RedactValue::Null, &mut rng);
46 assert!(matches!(result, RedactValue::Null));
47 }
48}