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

getdozer / dozer / 4370280743

pending completion
4370280743

push

github

GitHub
Bump async-trait from 0.1.65 to 0.1.66 (#1179)

27808 of 38702 relevant lines covered (71.85%)

25323.55 hits per line

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

69.7
/dozer-cache/src/cache/lmdb/tests/basic.rs
1
use crate::cache::{
2
    expression::{self, FilterExpression, QueryExpression, Skip},
3
    index,
4
    lmdb::cache::LmdbRwCache,
5
    test_utils::{self, query_from_filter},
6
    RoCache, RwCache,
7
};
8
use dozer_types::{
9
    serde_json::Value,
10
    types::{Field, Record, Schema},
11
};
12

13
use super::utils::create_cache;
14

15
fn _setup() -> (LmdbRwCache, Schema) {
4✔
16
    let (cache, schema, _) = create_cache(test_utils::schema_0);
4✔
17
    (cache, schema)
4✔
18
}
4✔
19

×
20
fn _setup_empty_primary_index() -> (LmdbRwCache, Schema) {
1✔
21
    let (cache, schema, _) = create_cache(test_utils::schema_empty_primary_index);
1✔
22
    (cache, schema)
1✔
23
}
1✔
24

×
25
fn query_and_test(cache: &dyn RwCache, inserted_record: &Record, exp: &QueryExpression) {
4✔
26
    let records = cache.query(exp).unwrap();
4✔
27
    assert_eq!(records[0].record, inserted_record.clone(), "must be equal");
4✔
28
}
4✔
29

×
30
#[test]
1✔
31
fn get_schema() {
1✔
32
    let (cache, schema) = _setup();
1✔
33

1✔
34
    let get_schema = &cache.get_schema().unwrap().0;
1✔
35
    assert_eq!(get_schema, &schema, "must be equal");
1✔
36
}
1✔
37

×
38
#[test]
1✔
39
fn insert_get_and_delete_record() {
1✔
40
    let val = "bar".to_string();
1✔
41
    let (cache, schema) = _setup();
1✔
42

1✔
43
    assert_eq!(cache.count(&QueryExpression::with_no_limit()).unwrap(), 0);
1✔
44

×
45
    let mut record = Record::new(schema.identifier, vec![Field::String(val.clone())], None);
1✔
46
    cache.insert(&mut record).unwrap();
1✔
47

1✔
48
    assert_eq!(cache.count(&QueryExpression::with_no_limit()).unwrap(), 1);
1✔
49

×
50
    let version = record.version.unwrap();
1✔
51

1✔
52
    let key = index::get_primary_key(&[0], &[Field::String(val)]);
1✔
53

1✔
54
    let get_record = cache.get(&key).unwrap().record;
1✔
55
    assert_eq!(get_record, record, "must be equal");
1✔
56

×
57
    assert_eq!(cache.delete(&key).unwrap(), version);
1✔
58
    assert_eq!(cache.count(&QueryExpression::with_no_limit()).unwrap(), 0);
1✔
59

×
60
    cache.get(&key).expect_err("Must not find a record");
1✔
61

1✔
62
    assert_eq!(cache.query(&QueryExpression::default()).unwrap(), vec![]);
1✔
63
}
1✔
64

×
65
#[test]
1✔
66
fn insert_and_update_record() {
1✔
67
    let (cache, schema) = _setup();
1✔
68
    let mut foo = Record::new(
1✔
69
        schema.identifier,
1✔
70
        vec![Field::String("foo".to_string())],
1✔
71
        None,
1✔
72
    );
1✔
73
    let mut bar = Record::new(
1✔
74
        schema.identifier,
1✔
75
        vec![Field::String("bar".to_string())],
1✔
76
        None,
1✔
77
    );
1✔
78
    cache.insert(&mut foo).unwrap();
1✔
79
    let old_version = foo.version.unwrap();
1✔
80
    cache.insert(&mut bar).unwrap();
1✔
81

1✔
82
    let key = index::get_primary_key(&schema.primary_index, &foo.values);
1✔
83

1✔
84
    assert_eq!(cache.update(&key, &mut foo).unwrap(), old_version);
1✔
85
    assert_eq!(foo.version.unwrap(), old_version + 1);
1✔
86
}
1✔
87

×
88
fn insert_and_query_record_impl(cache: LmdbRwCache, schema: Schema) {
2✔
89
    let val = "bar".to_string();
2✔
90
    let mut record = Record::new(schema.identifier, vec![Field::String(val)], None);
2✔
91

2✔
92
    cache.insert(&mut record).unwrap();
2✔
93

2✔
94
    // Query with an expression
2✔
95
    let exp = query_from_filter(FilterExpression::Simple(
2✔
96
        "foo".to_string(),
2✔
97
        expression::Operator::EQ,
2✔
98
        Value::from("bar".to_string()),
2✔
99
    ));
2✔
100

2✔
101
    query_and_test(&cache, &record, &exp);
2✔
102

2✔
103
    // Query without an expression
2✔
104
    query_and_test(
2✔
105
        &cache,
2✔
106
        &record,
2✔
107
        &QueryExpression::new(None, vec![], Some(10), Skip::Skip(0)),
2✔
108
    );
2✔
109
}
2✔
110

×
111
#[test]
1✔
112
fn insert_and_query_record() {
1✔
113
    let (cache, schema) = _setup();
1✔
114
    insert_and_query_record_impl(cache, schema);
1✔
115
    let (cache, schema) = _setup_empty_primary_index();
1✔
116
    insert_and_query_record_impl(cache, schema);
1✔
117
}
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