• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4382580286

pending completion
4382580286

push

github

GitHub
feat: Separate cache operation log environment and index environments (#1199)

1370 of 1370 new or added lines in 33 files covered. (100.0%)

28671 of 41023 relevant lines covered (69.89%)

51121.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.11
/dozer-cache/src/cache/plan/tests.rs
1
use super::{Plan, QueryPlanner};
2
use crate::cache::{
3
    expression::{self, FilterExpression, Operator, SortDirection, SortOption, SortOptions},
4
    plan::{IndexScanKind, SortedInvertedRangeQuery},
5
    test_utils,
6
};
7

8
use dozer_types::{serde_json::Value, types::Field};
9

10
#[test]
1✔
11
fn test_generate_plan_simple() {
1✔
12
    let (schema, secondary_indexes) = test_utils::schema_0();
1✔
13

1✔
14
    let filter = FilterExpression::Simple(
1✔
15
        "foo".to_string(),
1✔
16
        expression::Operator::EQ,
1✔
17
        Value::from("bar".to_string()),
1✔
18
    );
1✔
19
    let plan = QueryPlanner::new(
1✔
20
        &schema,
1✔
21
        &secondary_indexes,
1✔
22
        Some(&filter),
1✔
23
        &Default::default(),
1✔
24
    )
1✔
25
    .plan()
1✔
26
    .unwrap();
1✔
27
    if let Plan::IndexScans(index_scans) = plan {
1✔
28
        assert_eq!(index_scans.len(), 1);
1✔
29
        assert_eq!(index_scans[0].index_id, 0);
1✔
30
        match &index_scans[0].kind {
1✔
31
            IndexScanKind::SortedInverted {
×
32
                eq_filters,
1✔
33
                range_query,
1✔
34
            } => {
1✔
35
                assert_eq!(eq_filters.len(), 1);
1✔
36
                assert_eq!(eq_filters[0], (0, Field::String("bar".to_string())));
1✔
37
                assert_eq!(range_query, &None);
1✔
38
            }
39
            _ => panic!("Must be sorted inverted"),
×
40
        }
41
    } else {
×
42
        panic!("IndexScan expected")
×
43
    }
×
44
}
1✔
45

×
46
#[test]
1✔
47
fn test_generate_plan_and() {
1✔
48
    let (schema, secondary_indexes) = test_utils::schema_1();
1✔
49

1✔
50
    let filter = FilterExpression::And(vec![
1✔
51
        FilterExpression::Simple("a".to_string(), expression::Operator::EQ, Value::from(1)),
1✔
52
        FilterExpression::Simple(
1✔
53
            "b".to_string(),
1✔
54
            expression::Operator::EQ,
1✔
55
            Value::from("test".to_string()),
1✔
56
        ),
1✔
57
    ]);
1✔
58
    let plan = QueryPlanner::new(
1✔
59
        &schema,
1✔
60
        &secondary_indexes,
1✔
61
        Some(&filter),
1✔
62
        &Default::default(),
1✔
63
    )
1✔
64
    .plan()
1✔
65
    .unwrap();
1✔
66
    // Pick the 3rd index
×
67
    if let Plan::IndexScans(index_scans) = plan {
1✔
68
        assert_eq!(index_scans.len(), 1);
1✔
69
        assert_eq!(index_scans[0].index_id, 3);
1✔
70
        match &index_scans[0].kind {
1✔
71
            IndexScanKind::SortedInverted {
72
                eq_filters,
1✔
73
                range_query,
1✔
74
            } => {
1✔
75
                assert_eq!(eq_filters.len(), 2);
1✔
76
                assert_eq!(eq_filters[0], (0, Field::Int(1)));
1✔
77
                assert_eq!(eq_filters[1], (1, Field::String("test".to_string())));
1✔
78
                assert_eq!(range_query, &None);
1✔
79
            }
×
80
            _ => panic!("Must be sorted inverted"),
×
81
        }
×
82
    } else {
×
83
        panic!("IndexScan expected")
×
84
    }
×
85
}
1✔
86

×
87
#[test]
1✔
88
fn test_generate_plan_range_query_and_order_by() {
1✔
89
    let (schema, secondary_indexes) = test_utils::schema_1();
1✔
90
    let filter = FilterExpression::Simple("c".into(), expression::Operator::GT, 1.into());
1✔
91
    let order_by = SortOptions(vec![SortOption {
1✔
92
        field_name: "c".into(),
1✔
93
        direction: SortDirection::Descending,
1✔
94
    }]);
1✔
95
    let planner = QueryPlanner::new(&schema, &secondary_indexes, Some(&filter), &order_by);
1✔
96
    if let Plan::IndexScans(index_scans) = planner.plan().unwrap() {
1✔
97
        assert_eq!(index_scans.len(), 1);
1✔
98
        assert_eq!(index_scans[0].index_id, 2);
1✔
99
        match &index_scans[0].kind {
1✔
100
            IndexScanKind::SortedInverted {
×
101
                eq_filters,
1✔
102
                range_query,
1✔
103
            } => {
1✔
104
                assert_eq!(eq_filters.len(), 0);
1✔
105
                assert_eq!(
1✔
106
                    range_query,
1✔
107
                    &Some(SortedInvertedRangeQuery {
1✔
108
                        field_index: 2,
1✔
109
                        sort_direction: SortDirection::Descending,
1✔
110
                        operator_and_value: Some((expression::Operator::GT, 1.into())),
1✔
111
                    })
1✔
112
                );
1✔
113
            }
×
114
            _ => panic!("Must be sorted inverted"),
×
115
        }
×
116
    } else {
×
117
        panic!("IndexScan expected")
×
118
    }
×
119
}
1✔
120

×
121
#[test]
1✔
122
fn test_generate_plan_empty() {
1✔
123
    let (schema, secondary_indexes) = test_utils::schema_1();
1✔
124

1✔
125
    let filter = FilterExpression::Simple("c".into(), Operator::LT, Value::Null);
1✔
126
    let plan = QueryPlanner::new(
1✔
127
        &schema,
1✔
128
        &secondary_indexes,
1✔
129
        Some(&filter),
1✔
130
        &Default::default(),
1✔
131
    )
1✔
132
    .plan()
1✔
133
    .unwrap();
1✔
134
    assert!(matches!(plan, Plan::ReturnEmpty));
1✔
135
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc