Skip to content

Commit

Permalink
Use pretty_assertions in tests (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-tkach committed Aug 7, 2020
1 parent d0e1ebd commit 4a064d0
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -32,3 +32,4 @@ librocksdb-sys = { path = "librocksdb-sys", version = "6.10.2" }
[dev-dependencies]
trybuild = "1.0.21"
tempfile = "3.1.0"
pretty_assertions = "0.6.1"
2 changes: 2 additions & 0 deletions tests/test_backup.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{
backup::{BackupEngine, BackupEngineOptions, RestoreOptions},
DB,
Expand Down
26 changes: 14 additions & 12 deletions tests/test_checkpoint.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{checkpoint::Checkpoint, Options, DB};
use util::DBPath;

Expand Down Expand Up @@ -41,10 +43,10 @@ pub fn test_single_checkpoint() {
// Verify checkpoint
let cp = DB::open_default(&cp1_path).unwrap();

assert_eq!(*cp.get(b"k1").unwrap().unwrap(), *b"v1");
assert_eq!(*cp.get(b"k2").unwrap().unwrap(), *b"v2");
assert_eq!(*cp.get(b"k3").unwrap().unwrap(), *b"v3");
assert_eq!(*cp.get(b"k4").unwrap().unwrap(), *b"v4");
assert_eq!(cp.get(b"k1").unwrap().unwrap(), b"v1");
assert_eq!(cp.get(b"k2").unwrap().unwrap(), b"v2");
assert_eq!(cp.get(b"k3").unwrap().unwrap(), b"v3");
assert_eq!(cp.get(b"k4").unwrap().unwrap(), b"v4");
}

#[test]
Expand All @@ -71,10 +73,10 @@ pub fn test_multi_checkpoints() {
// Verify checkpoint
let cp = DB::open_default(&cp1_path).unwrap();

assert_eq!(*cp.get(b"k1").unwrap().unwrap(), *b"v1");
assert_eq!(*cp.get(b"k2").unwrap().unwrap(), *b"v2");
assert_eq!(*cp.get(b"k3").unwrap().unwrap(), *b"v3");
assert_eq!(*cp.get(b"k4").unwrap().unwrap(), *b"v4");
assert_eq!(cp.get(b"k1").unwrap().unwrap(), b"v1");
assert_eq!(cp.get(b"k2").unwrap().unwrap(), b"v2");
assert_eq!(cp.get(b"k3").unwrap().unwrap(), b"v3");
assert_eq!(cp.get(b"k4").unwrap().unwrap(), b"v4");

// Change some existing keys
db.put(b"k1", b"modified").unwrap();
Expand All @@ -92,8 +94,8 @@ pub fn test_multi_checkpoints() {
// Verify second checkpoint
let cp = DB::open_default(&cp2_path).unwrap();

assert_eq!(*cp.get(b"k1").unwrap().unwrap(), *b"modified");
assert_eq!(*cp.get(b"k2").unwrap().unwrap(), *b"changed");
assert_eq!(*cp.get(b"k5").unwrap().unwrap(), *b"v5");
assert_eq!(*cp.get(b"k6").unwrap().unwrap(), *b"v6");
assert_eq!(cp.get(b"k1").unwrap().unwrap(), b"modified");
assert_eq!(cp.get(b"k2").unwrap().unwrap(), b"changed");
assert_eq!(cp.get(b"k5").unwrap().unwrap(), b"v5");
assert_eq!(cp.get(b"k6").unwrap().unwrap(), b"v6");
}
2 changes: 2 additions & 0 deletions tests/test_column_family.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{ColumnFamilyDescriptor, MergeOperands, Options, DB, DEFAULT_COLUMN_FAMILY_NAME};
use util::DBPath;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_compationfilter.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{CompactionDecision, Options, DB};
use util::DBPath;

Expand Down
7 changes: 4 additions & 3 deletions tests/test_db.rs
Expand Up @@ -14,15 +14,16 @@

mod util;

use std::{mem, sync::Arc, thread, time::Duration};

use pretty_assertions::assert_eq;

use rocksdb::{
perf::get_memory_usage_stats, BlockBasedOptions, BottommostLevelCompaction, Cache,
CompactOptions, DBCompactionStyle, Env, Error, FifoCompactOptions, IteratorMode, Options,
PerfContext, PerfMetric, ReadOptions, SliceTransform, Snapshot, UniversalCompactOptions,
UniversalCompactionStopStyle, WriteBatch, DB,
};
use std::sync::Arc;
use std::time::Duration;
use std::{mem, thread};
use util::DBPath;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_iterator.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{Direction, IteratorMode, MemtableFactory, Options, DB};
use util::DBPath;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_merge_operator.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{DBCompactionStyle, MergeOperands, Options, DB};
use util::DBPath;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_multithreaded.rs
Expand Up @@ -14,9 +14,9 @@

mod util;

use std::{sync::Arc, thread};

use rocksdb::DB;
use std::sync::Arc;
use std::thread;
use util::DBPath;

const N: usize = 100_000;
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pinnable_slice.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{Options, DB};
use util::DBPath;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_property.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{Options, DB};
use util::DBPath;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_raw_iterator.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::DB;
use util::DBPath;

Expand Down
3 changes: 2 additions & 1 deletion tests/test_rocksdb_options.rs
Expand Up @@ -14,8 +14,9 @@

mod util;

use rocksdb::{BlockBasedOptions, DataBlockIndexType, Options, ReadOptions, DB};
use std::{fs, io::Read as _};

use rocksdb::{BlockBasedOptions, DataBlockIndexType, Options, ReadOptions, DB};
use util::DBPath;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_slice_transform.rs
Expand Up @@ -14,6 +14,8 @@

mod util;

use pretty_assertions::assert_eq;

use rocksdb::{Options, SliceTransform, DB};
use util::DBPath;

Expand Down
3 changes: 2 additions & 1 deletion tests/test_sst_file_writer.rs
Expand Up @@ -14,8 +14,9 @@

mod util;

use rocksdb::{Error, Options, SstFileWriter, DB};
use pretty_assertions::assert_eq;

use rocksdb::{Error, Options, SstFileWriter, DB};
use util::DBPath;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_write_batch.rs
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use pretty_assertions::assert_eq;

use rocksdb::WriteBatch;

#[test]
Expand Down

0 comments on commit 4a064d0

Please sign in to comment.