Merge pull request #28 from thijsc/bson_09

Upgrade bson dependency to 0.9
pull/30/head
Thijs Cadier 7 years ago committed by GitHub
commit bfecc69775

@ -13,13 +13,13 @@ license = "MIT/Apache-2.0"
name = "tests" name = "tests"
[dependencies] [dependencies]
libc = "0.2" libc = "^0.2"
log = "0.3" log = "^0.3"
bson = "0.8" bson = "^0.9"
[dependencies.mongoc-sys] [dependencies.mongoc-sys]
path = "mongoc-sys" path = "mongoc-sys"
version = "1.6.3" version = "1.6.3"
[dev-dependencies] [dev-dependencies]
chrono = "= 0.3.0" chrono = "^0.4"

@ -1,4 +1,4 @@
use chrono::*; use chrono::prelude::*;
use mongo_driver::client::{ClientPool,Uri}; 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"); let mut collection = client.get_collection("rust_driver_test", "bson");
collection.drop().unwrap_or(()); 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! { let document = doc! {
"_id" => (ObjectId::new().unwrap()), "_id" => (ObjectId::new().unwrap()),
"floating_point" => 10.0, "floating_point" => 10.0,

@ -60,8 +60,8 @@ fn test_insert_remove_replace_update_extended() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!( assert_eq!(
result.ok().unwrap().get("nInserted").unwrap().to_json(), result.ok().unwrap().get("nInserted").unwrap(),
bson::Bson::I32(5).to_json() &bson::Bson::I32(5)
); );
assert_eq!(5, collection.count(&doc!{}, None).unwrap()); assert_eq!(5, collection.count(&doc!{}, None).unwrap());
} }
@ -86,14 +86,14 @@ fn test_insert_remove_replace_update_extended() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!( assert_eq!(
result.ok().unwrap().get("nModified").unwrap().to_json(), result.ok().unwrap().get("nModified").unwrap(),
bson::Bson::I32(1).to_json() &bson::Bson::I32(1)
); );
let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap();
assert_eq!( assert_eq!(
first_document.get("key_1").unwrap().to_json(), first_document.get("key_1").unwrap(),
bson::Bson::String("Value update".to_string()).to_json() &bson::Bson::String("Value update".to_string())
); );
// Make sure it was updated, it should have other keys // Make sure it was updated, it should have other keys
assert!(first_document.get("key_2").is_some()); assert!(first_document.get("key_2").is_some());
@ -113,15 +113,15 @@ fn test_insert_remove_replace_update_extended() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!( assert_eq!(
result.ok().unwrap().get("nModified").unwrap().to_json(), result.ok().unwrap().get("nModified").unwrap(),
bson::Bson::I32(4).to_json() &bson::Bson::I32(4)
); );
collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap();
let second_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); let second_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap();
assert_eq!( assert_eq!(
second_document.get("key_1").unwrap().to_json(), second_document.get("key_1").unwrap(),
bson::Bson::String("Value update".to_string()).to_json() &bson::Bson::String("Value update".to_string())
); );
// Make sure it was updated, it should have other keys // Make sure it was updated, it should have other keys
assert!(second_document.get("key_2").is_some()); assert!(second_document.get("key_2").is_some());
@ -142,14 +142,14 @@ fn test_insert_remove_replace_update_extended() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!( assert_eq!(
result.ok().unwrap().get("nModified").unwrap().to_json(), result.ok().unwrap().get("nModified").unwrap(),
bson::Bson::I32(1).to_json() &bson::Bson::I32(1)
); );
let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap(); let first_document = collection.find(&doc!{}, None).unwrap().next().unwrap().unwrap();
assert_eq!( assert_eq!(
first_document.get("key_1").unwrap().to_json(), first_document.get("key_1").unwrap(),
bson::Bson::String("Value replace".to_string()).to_json() &bson::Bson::String("Value replace".to_string())
); );
// Make sure it was replaced, it shouldn't have other keys // Make sure it was replaced, it shouldn't have other keys
assert!(first_document.get("key_2").is_none()); assert!(first_document.get("key_2").is_none());
@ -164,8 +164,8 @@ fn test_insert_remove_replace_update_extended() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!( assert_eq!(
result.ok().unwrap().get("nRemoved").unwrap().to_json(), result.ok().unwrap().get("nRemoved").unwrap(),
bson::Bson::I32(1).to_json() &bson::Bson::I32(1)
); );
assert_eq!(4, collection.count(&query, None).unwrap()); assert_eq!(4, collection.count(&query, None).unwrap());
} }
@ -179,8 +179,8 @@ fn test_insert_remove_replace_update_extended() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!( assert_eq!(
result.ok().unwrap().get("nRemoved").unwrap().to_json(), result.ok().unwrap().get("nRemoved").unwrap(),
bson::Bson::I32(4).to_json() &bson::Bson::I32(4)
); );
assert_eq!(0, collection.count(&query, None).unwrap()); assert_eq!(0, collection.count(&query, None).unwrap());
} }

@ -93,13 +93,13 @@ fn test_mutation_and_finding() {
// Find the documents // Find the documents
assert_eq!( assert_eq!(
collection.find(&document, None).unwrap().next().unwrap().unwrap().get("key_1").unwrap().to_json(), collection.find(&document, None).unwrap().next().unwrap().unwrap().get("key_1").unwrap(),
bson::Bson::String("Value 1".to_string()).to_json() &bson::Bson::String("Value 1".to_string())
); );
let found_document = collection.find(&second_document, None).unwrap().next().unwrap().unwrap(); let found_document = collection.find(&second_document, None).unwrap().next().unwrap().unwrap();
assert_eq!( assert_eq!(
found_document.get("key_1").unwrap().to_json(), found_document.get("key_1").unwrap(),
bson::Bson::String("Value 3".to_string()).to_json() &bson::Bson::String("Value 3".to_string())
); );
// Update the second document // 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(); let mut found_document = collection.find(&query_after_update, None).unwrap().next().unwrap().unwrap();
assert_eq!( assert_eq!(
found_document.get("key_1").unwrap().to_json(), found_document.get("key_1").unwrap(),
bson::Bson::String("Value 4".to_string()).to_json() &bson::Bson::String("Value 4".to_string())
); );
// Save the second document // Save the second document
@ -123,8 +123,8 @@ fn test_mutation_and_finding() {
// Reload and check value // Reload and check value
let found_document = collection.find(&found_document, None).unwrap().next().unwrap().unwrap(); let found_document = collection.find(&found_document, None).unwrap().next().unwrap().unwrap();
assert_eq!( assert_eq!(
found_document.get("key_1").unwrap().to_json(), found_document.get("key_1").unwrap(),
bson::Bson::String("Value 5".to_string()).to_json() &bson::Bson::String("Value 5".to_string())
); );
// Remove one // Remove one

Loading…
Cancel
Save