tglman / persy
Showing 1 of 1 files from the diff.

@@ -358,45 +358,42 @@
Loading
358 358
359 359
#[test]
360 360
fn test_multiple_put_remove_same_value_intervalled_get() {
361 -
    create_and_drop_index(
362 -
        "multiple_put remove_same_value_interrvalled_get",
363 -
        |persy, index_name| {
364 -
            let mut tx = persy.begin().expect("begin transaction works");
365 -
            tx.put::<u8, u8>(index_name, 10, 12).expect("put works correctly");
366 -
            tx.put::<u8, u8>(index_name, 10, 13).expect("put works correctly");
367 -
            tx.put::<u8, u8>(index_name, 10, 14).expect("put works correctly");
368 -
            tx.put::<u8, u8>(index_name, 10, 12).expect("put works correctly");
361 +
    create_and_drop_index("multiple_put remove_same_value_intervalled_get", |persy, index_name| {
362 +
        let mut tx = persy.begin().expect("begin transaction works");
363 +
        tx.put::<u8, u8>(index_name, 10, 12).expect("put works correctly");
364 +
        tx.put::<u8, u8>(index_name, 10, 13).expect("put works correctly");
365 +
        tx.put::<u8, u8>(index_name, 10, 14).expect("put works correctly");
366 +
        tx.put::<u8, u8>(index_name, 10, 12).expect("put works correctly");
369 367
370 -
            let prep = tx.prepare().expect("prepare with index works");
371 -
            prep.commit().expect("commit with index works");
372 -
            let mut res = persy.get::<u8, u8>(index_name, &10).expect("get works correctly");
373 -
            assert_eq!(res.next(), Some(12));
374 -
            assert_eq!(res.next(), Some(13));
375 -
            assert_eq!(res.next(), Some(14));
376 -
            assert_eq!(res.next(), None);
368 +
        let prep = tx.prepare().expect("prepare with index works");
369 +
        prep.commit().expect("commit with index works");
370 +
        let mut res = persy.get::<u8, u8>(index_name, &10).expect("get works correctly");
371 +
        assert_eq!(res.next(), Some(12));
372 +
        assert_eq!(res.next(), Some(13));
373 +
        assert_eq!(res.next(), Some(14));
374 +
        assert_eq!(res.next(), None);
377 375
378 -
            let mut tx = persy.begin().expect("begin transaction works");
379 -
            tx.remove::<u8, u8>(index_name, 10, Some(12))
380 -
                .expect("put works correctly");
381 -
            tx.remove::<u8, u8>(index_name, 10, Some(11))
382 -
                .expect("put works correctly");
383 -
            tx.remove::<u8, u8>(index_name, 10, Some(13))
384 -
                .expect("put works correctly");
385 -
            tx.remove::<u8, u8>(index_name, 10, Some(12))
386 -
                .expect("put works correctly");
387 -
            tx.remove::<u8, u8>(index_name, 10, Some(13))
388 -
                .expect("put works correctly");
389 -
            let mut res = tx.get::<u8, u8>(index_name, &10).expect("get works correctly");
390 -
            assert_eq!(res.next(), Some(14));
391 -
            assert_eq!(res.next(), None);
392 -
            let prep = tx.prepare().expect("prepare with index works");
393 -
            prep.commit().expect("commit with index works");
376 +
        let mut tx = persy.begin().expect("begin transaction works");
377 +
        tx.remove::<u8, u8>(index_name, 10, Some(12))
378 +
            .expect("put works correctly");
379 +
        tx.remove::<u8, u8>(index_name, 10, Some(11))
380 +
            .expect("put works correctly");
381 +
        tx.remove::<u8, u8>(index_name, 10, Some(13))
382 +
            .expect("put works correctly");
383 +
        tx.remove::<u8, u8>(index_name, 10, Some(12))
384 +
            .expect("put works correctly");
385 +
        tx.remove::<u8, u8>(index_name, 10, Some(13))
386 +
            .expect("put works correctly");
387 +
        let mut res = tx.get::<u8, u8>(index_name, &10).expect("get works correctly");
388 +
        assert_eq!(res.next(), Some(14));
389 +
        assert_eq!(res.next(), None);
390 +
        let prep = tx.prepare().expect("prepare with index works");
391 +
        prep.commit().expect("commit with index works");
394 392
395 -
            let mut res = persy.get::<u8, u8>(index_name, &10).expect("get works correctly");
396 -
            assert_eq!(res.next(), Some(14));
397 -
            assert_eq!(res.next(), None);
398 -
        },
399 -
    );
393 +
        let mut res = persy.get::<u8, u8>(index_name, &10).expect("get works correctly");
394 +
        assert_eq!(res.next(), Some(14));
395 +
        assert_eq!(res.next(), None);
396 +
    });
400 397
}
401 398
#[test]
402 399
fn test_multiple_put_same_value_intervalled_get_same_tx() {
@@ -800,3 +797,58 @@
Loading
800 797
        assert_eq!(segments.len(), 0);
801 798
    });
802 799
}
800 +
801 +
#[test]
802 +
fn test_grow_and_shrink() {
803 +
    create_and_drop("grow_and_shrink", |persy| {
804 +
        let mut tx = persy.begin().expect("begin transaction works");
805 +
        let index_name = "grow_and_shrink";
806 +
        tx.create_index::<i32, i32>(index_name, ValueMode::Cluster).unwrap();
807 +
        let prep = tx.prepare().expect("prepare with index works");
808 +
        prep.commit().expect("commit with index works");
809 +
        let mut tx = persy.begin().expect("begin transaction works");
810 +
        for v in 0..1000 {
811 +
            tx.put::<i32, i32>(index_name, v, 12).expect("put works correctly");
812 +
            tx.put::<i32, i32>(index_name, v, 13).expect("put works correctly");
813 +
            tx.put::<i32, i32>(index_name, v, 14).expect("put works correctly");
814 +
            if v % 100 == 0 {
815 +
                let prep = tx.prepare().expect("prepare with index works");
816 +
                prep.commit().expect("commit with index works");
817 +
                tx = persy.begin().expect("begin transaction works");
818 +
            }
819 +
        }
820 +
        let prep = tx.prepare().expect("prepare with index works");
821 +
        prep.commit().expect("commit with index works");
822 +
823 +
        let mut res = persy.get::<i32, i32>(index_name, &10).expect("get works correctly");
824 +
        assert_eq!(res.next(), Some(12));
825 +
        assert_eq!(res.next(), Some(13));
826 +
        assert_eq!(res.next(), Some(14));
827 +
        assert_eq!(res.next(), None);
828 +
        let count = persy
829 +
            .range::<i32, i32, _>(index_name, ..)
830 +
            .expect("get works correctly")
831 +
            .count();
832 +
        assert_eq!(count, 1000);
833 +
834 +
        let mut tx = persy.begin().expect("begin transaction works");
835 +
        for v in 0..1000 {
836 +
            tx.remove::<i32, i32>(index_name, v, None).expect("put works correctly");
837 +
            if v % 100 == 0 {
838 +
                let prep = tx.prepare().expect("prepare with index works");
839 +
                prep.commit().expect("commit with index works");
840 +
                tx = persy.begin().expect("begin transaction works");
841 +
            }
842 +
        }
843 +
        let prep = tx.prepare().expect("prepare with index works");
844 +
        prep.commit().expect("commit with index works");
845 +
846 +
        let mut res = persy.get::<i32, i32>(index_name, &10).expect("get works correctly");
847 +
        assert_eq!(res.next(), None);
848 +
        let count = persy
849 +
            .range::<i32, i32, _>(index_name, ..)
850 +
            .expect("get works correctly")
851 +
            .count();
852 +
        assert_eq!(count, 0);
853 +
    });
854 +
}
Files Coverage
src 91.70%
tests 98.71%
Project Totals (37 files) 93.07%
Notifications are pending CI completion. Waiting for GitLab's status webhook to queue notifications. Push notifications now.
1
coverage:
2
  status:
3
    project:
4
      default:
5
        target: 80%
6
        threshold: 1.0%
7
    patch: off
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading