#[cfg(test)]
mod compaction_tests {
    use crate::utils::{db_put_simple, open_database, tmpdir};
    use leveldb::compaction::Compaction;
    use leveldb::database::Slice;

    #[test]
    fn test_compact_all() {
        let tmp = tmpdir("compact_all");
        let database = &mut open_database(tmp.path(), true);
        db_put_simple(database, &[1], &[1]);
        db_put_simple(database, &[2], &[2]);
        db_put_simple(database, &[3], &[3]);
        db_put_simple(database, &[4], &[4]);
        db_put_simple(database, &[5], &[5]);

        database.compact_all();
    }

    #[test]
    fn test_compact_from() {
        let tmp = tmpdir("compact_from");
        let database = &mut open_database(tmp.path(), true);
        db_put_simple(database, &[1], &[1]);
        db_put_simple(database, &[2], &[2]);
        db_put_simple(database, &[3], &[3]);
        db_put_simple(database, &[4], &[4]);
        db_put_simple(database, &[5], &[5]);

        let from = Slice::from(&[2][..]);
        database.compact_from(from);
    }

    #[test]
    fn test_compact_until() {
        let tmp = tmpdir("compact_until");
        let database = &mut open_database(tmp.path(), true);
        db_put_simple(database, &[1], &[1]);
        db_put_simple(database, &[2], &[2]);
        db_put_simple(database, &[3], &[3]);
        db_put_simple(database, &[4], &[4]);
        db_put_simple(database, &[5], &[5]);

        let to = Slice::from(&[4][..]);
        database.compact_until(to);
    }

    #[test]
    fn test_compact_from_to() {
        let tmp = tmpdir("compact");
        let database = &mut open_database(tmp.path(), true);
        db_put_simple(database, &[1], &[1]);
        db_put_simple(database, &[2], &[2]);
        db_put_simple(database, &[3], &[3]);
        db_put_simple(database, &[4], &[4]);
        db_put_simple(database, &[5], &[5]);

        let from = Slice::from(&[2][..]);
        let to = Slice::from(&[4][..]);
        database.compact(from, to);
    }
}
