Upgrade bson dependency to 0.9

pull/28/head
Thijs Cadier 7 years ago
parent 70a9a75101
commit 074974f715

@ -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"

@ -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,

@ -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());
}

@ -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

Loading…
Cancel
Save