• 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

93.65
/dozer-cache/src/cache/lmdb/tests/read_write.rs
1
use crate::cache::expression::{FilterExpression, Operator, QueryExpression};
2
use crate::cache::lmdb::cache::{CacheCommonOptions, CacheWriteOptions, LmdbRoCache, LmdbRwCache};
3
use crate::cache::{lmdb::tests::utils as lmdb_utils, test_utils, RoCache, RwCache};
4
use dozer_types::serde_json::Value;
5
use dozer_types::types::Field;
6
use tempdir::TempDir;
7
#[test]
1✔
8
fn read_and_write() {
1✔
9
    let path = TempDir::new("dozer").unwrap();
1✔
10
    let path = (path.path().to_path_buf(), "cache".to_string());
1✔
11

1✔
12
    // write and read from cache from two different threads.
1✔
13

1✔
14
    let (schema, secondary_indexes) = test_utils::schema_1();
1✔
15
    let cache_writer = LmdbRwCache::create(
1✔
16
        schema.clone(),
1✔
17
        secondary_indexes,
1✔
18
        CacheCommonOptions {
1✔
19
            max_readers: 1,
1✔
20
            max_db_size: 100,
1✔
21
            path: Some(path.clone()),
1✔
22
            intersection_chunk_size: 1,
1✔
23
        },
1✔
24
        CacheWriteOptions {
1✔
25
            max_size: 1024 * 1024,
1✔
26
        },
1✔
27
    )
1✔
28
    .unwrap();
1✔
29

1✔
30
    let items = vec![
1✔
31
        (1, Some("a".to_string()), Some(521)),
1✔
32
        (2, Some("a".to_string()), None),
1✔
33
        (3, None, Some(521)),
1✔
34
        (4, None, None),
1✔
35
    ];
1✔
36

37
    for val in items.clone() {
4✔
38
        lmdb_utils::insert_rec_1(&cache_writer, &schema, val.clone());
4✔
39
    }
4✔
40
    cache_writer.commit().unwrap();
1✔
41

1✔
42
    let read_options = CacheCommonOptions {
1✔
43
        path: Some(path),
1✔
44
        ..Default::default()
1✔
45
    };
1✔
46
    let cache_reader = LmdbRoCache::new(read_options).unwrap();
1✔
47
    for (a, b, c) in items {
5✔
48
        let rec = cache_reader.get(&Field::Int(a).encode()).unwrap();
4✔
49
        let values = vec![
4✔
50
            Field::Int(a),
4✔
51
            b.map_or(Field::Null, Field::String),
4✔
52
            c.map_or(Field::Null, Field::Int),
4✔
53
        ];
4✔
54
        assert_eq!(rec.record.values, values, "should be equal");
4✔
55
    }
56
    let records = cache_reader
1✔
57
        .query(&QueryExpression {
1✔
58
            filter: Some(FilterExpression::Simple(
1✔
59
                "a".to_string(),
1✔
60
                Operator::EQ,
1✔
61
                Value::from(1),
1✔
62
            )),
1✔
63
            ..Default::default()
1✔
64
        })
1✔
65
        .unwrap();
1✔
66
    assert_eq!(records.len(), 1);
1✔
67
}
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