From 074974f715ec2bba8d1c9d29012396b9bddde653 Mon Sep 17 00:00:00 2001 From: Thijs Cadier Date: Sat, 24 Jun 2017 10:49:15 +0200 Subject: [PATCH] Upgrade bson dependency to 0.9 --- Cargo.toml | 8 ++++---- tests/bson_encode_decode.rs | 4 ++-- tests/bulk_operation.rs | 36 ++++++++++++++++++------------------ tests/collection.rs | 16 ++++++++-------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 39ae3c2..b2ae5fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,13 @@ license = "MIT/Apache-2.0" name = "tests" [dependencies] -libc = "0.2" -log = "0.3" -bson = "0.8" +libc = "^0.2" +log = "^0.3" +bson = "^0.9" [dependencies.mongoc-sys] path = "mongoc-sys" version = "1.6.3" [dev-dependencies] -chrono = "= 0.3.0" +chrono = "^0.4" diff --git a/tests/bson_encode_decode.rs b/tests/bson_encode_decode.rs index 9227e6e..3d0d73a 100644 --- a/tests/bson_encode_decode.rs +++ b/tests/bson_encode_decode.rs @@ -1,4 +1,4 @@ -use chrono::*; +use chrono::prelude::*; use mongo_driver::client::{ClientPool,Uri}; @@ -17,7 +17,7 @@ fn test_bson_encode_decode() { let mut collection = client.get_collection("rust_driver_test", "bson"); collection.drop().unwrap_or(()); - let datetime = UTC.ymd(2014, 7, 8).and_hms(9, 10, 11); + let datetime = Utc.ymd(2014, 7, 8).and_hms(9, 10, 11); let document = doc! { "_id" => (ObjectId::new().unwrap()), "floating_point" => 10.0, diff --git a/tests/bulk_operation.rs b/tests/bulk_operation.rs index cc8447c..ce2eba4 100644 --- a/tests/bulk_operation.rs +++ b/tests/bulk_operation.rs @@ -60,8 +60,8 @@ fn test_insert_remove_replace_update_extended() { assert!(result.is_ok()); assert_eq!( - result.ok().unwrap().get("nInserted").unwrap().to_json(), - bson::Bson::I32(5).to_json() + result.ok().unwrap().get("nInserted").unwrap(), + &bson::Bson::I32(5) ); assert_eq!(5, collection.count(&doc!{}, None).unwrap()); } @@ -86,14 +86,14 @@ fn test_insert_remove_replace_update_extended() { assert!(result.is_ok()); assert_eq!( - result.ok().unwrap().get("nModified").unwrap().to_json(), - bson::Bson::I32(1).to_json() + result.ok().unwrap().get("nModified").unwrap(), + &bson::Bson::I32(1) ); let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); assert_eq!( - first_document.get("key_1").unwrap().to_json(), - bson::Bson::String("Value update".to_string()).to_json() + first_document.get("key_1").unwrap(), + &bson::Bson::String("Value update".to_string()) ); // Make sure it was updated, it should have other keys assert!(first_document.get("key_2").is_some()); @@ -113,15 +113,15 @@ fn test_insert_remove_replace_update_extended() { assert!(result.is_ok()); assert_eq!( - result.ok().unwrap().get("nModified").unwrap().to_json(), - bson::Bson::I32(4).to_json() + result.ok().unwrap().get("nModified").unwrap(), + &bson::Bson::I32(4) ); collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); let second_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); assert_eq!( - second_document.get("key_1").unwrap().to_json(), - bson::Bson::String("Value update".to_string()).to_json() + second_document.get("key_1").unwrap(), + &bson::Bson::String("Value update".to_string()) ); // Make sure it was updated, it should have other keys assert!(second_document.get("key_2").is_some()); @@ -142,14 +142,14 @@ fn test_insert_remove_replace_update_extended() { assert!(result.is_ok()); assert_eq!( - result.ok().unwrap().get("nModified").unwrap().to_json(), - bson::Bson::I32(1).to_json() + result.ok().unwrap().get("nModified").unwrap(), + &bson::Bson::I32(1) ); let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); assert_eq!( - first_document.get("key_1").unwrap().to_json(), - bson::Bson::String("Value replace".to_string()).to_json() + first_document.get("key_1").unwrap(), + &bson::Bson::String("Value replace".to_string()) ); // Make sure it was replaced, it shouldn't have other keys assert!(first_document.get("key_2").is_none()); @@ -164,8 +164,8 @@ fn test_insert_remove_replace_update_extended() { assert!(result.is_ok()); assert_eq!( - result.ok().unwrap().get("nRemoved").unwrap().to_json(), - bson::Bson::I32(1).to_json() + result.ok().unwrap().get("nRemoved").unwrap(), + &bson::Bson::I32(1) ); assert_eq!(4, collection.count(&query, None).unwrap()); } @@ -179,8 +179,8 @@ fn test_insert_remove_replace_update_extended() { assert!(result.is_ok()); assert_eq!( - result.ok().unwrap().get("nRemoved").unwrap().to_json(), - bson::Bson::I32(4).to_json() + result.ok().unwrap().get("nRemoved").unwrap(), + &bson::Bson::I32(4) ); assert_eq!(0, collection.count(&query, None).unwrap()); } diff --git a/tests/collection.rs b/tests/collection.rs index 9644370..8c27686 100644 --- a/tests/collection.rs +++ b/tests/collection.rs @@ -93,13 +93,13 @@ fn test_mutation_and_finding() { // Find the documents assert_eq!( - collection.find(&document, None).unwrap().next().unwrap().unwrap().get("key_1").unwrap().to_json(), - bson::Bson::String("Value 1".to_string()).to_json() + collection.find(&document, None).unwrap().next().unwrap().unwrap().get("key_1").unwrap(), + &bson::Bson::String("Value 1".to_string()) ); let found_document = collection.find(&second_document, None).unwrap().next().unwrap().unwrap(); assert_eq!( - found_document.get("key_1").unwrap().to_json(), - bson::Bson::String("Value 3".to_string()).to_json() + found_document.get("key_1").unwrap(), + &bson::Bson::String("Value 3".to_string()) ); // Update the second document @@ -112,8 +112,8 @@ fn test_mutation_and_finding() { }; let mut found_document = collection.find(&query_after_update, None).unwrap().next().unwrap().unwrap(); assert_eq!( - found_document.get("key_1").unwrap().to_json(), - bson::Bson::String("Value 4".to_string()).to_json() + found_document.get("key_1").unwrap(), + &bson::Bson::String("Value 4".to_string()) ); // Save the second document @@ -123,8 +123,8 @@ fn test_mutation_and_finding() { // Reload and check value let found_document = collection.find(&found_document, None).unwrap().next().unwrap().unwrap(); assert_eq!( - found_document.get("key_1").unwrap().to_json(), - bson::Bson::String("Value 5".to_string()).to_json() + found_document.get("key_1").unwrap(), + &bson::Bson::String("Value 5".to_string()) ); // Remove one