@@ -6,27 +6,27 @@ use std::thread;
6
6
#[ test]
7
7
fn database_names ( ) {
8
8
let client = Client :: connect ( "localhost" , 27018 ) . unwrap ( ) ;
9
- let state_results = client. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
9
+ let state_results = client. database_names ( ) . expect ( "Failed to execute database_names." ) ;
10
10
for name in state_results {
11
11
if name != "local" {
12
- client. drop_database ( & name[ ..] ) . ok ( ) . expect ( "Failed to drop database from server." ) ;
12
+ client. drop_database ( & name[ ..] ) . expect ( "Failed to drop database from server." ) ;
13
13
}
14
14
}
15
15
16
- let base_results = client. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
16
+ let base_results = client. database_names ( ) . expect ( "Failed to execute database_names." ) ;
17
17
assert_eq ! ( 1 , base_results. len( ) ) ;
18
18
assert_eq ! ( "local" , base_results[ 0 ] ) ;
19
19
20
20
// Build dbs
21
21
let db1 = client. db ( "new_db" ) ;
22
22
let db2 = client. db ( "new_db_2" ) ;
23
23
db1. collection ( "test1" ) . insert_one ( bson:: Document :: new ( ) , None )
24
- . ok ( ) . expect ( "Failed to insert placeholder document into collection" ) ;
24
+ . expect ( "Failed to insert placeholder document into collection" ) ;
25
25
db2. collection ( "test2" ) . insert_one ( bson:: Document :: new ( ) , None )
26
- . ok ( ) . expect ( "Failed to insert placeholder document into collection" ) ;
26
+ . expect ( "Failed to insert placeholder document into collection" ) ;
27
27
28
28
// Check new dbs
29
- let results = client. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
29
+ let results = client. database_names ( ) . expect ( "Failed to execute database_names." ) ;
30
30
assert_eq ! ( 3 , results. len( ) ) ;
31
31
assert ! ( results. contains( & "local" . to_owned( ) ) ) ;
32
32
assert ! ( results. contains( & "new_db" . to_owned( ) ) ) ;
@@ -37,48 +37,48 @@ fn database_names() {
37
37
#[ test]
38
38
fn is_master ( ) {
39
39
let client = Client :: connect ( "localhost" , 27017 ) . unwrap ( ) ;
40
- let res = client. is_master ( ) . ok ( ) . expect ( "Failed to execute is_master." ) ;
40
+ let res = client. is_master ( ) . expect ( "Failed to execute is_master." ) ;
41
41
assert ! ( res) ;
42
42
}
43
43
44
44
#[ test]
45
45
fn is_sync ( ) {
46
46
let client = Client :: connect ( "localhost" , 27018 ) . unwrap ( ) ;
47
- let state_results = client. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
47
+ let state_results = client. database_names ( ) . expect ( "Failed to execute database_names." ) ;
48
48
for name in state_results {
49
49
if name != "local" {
50
- client. drop_database ( & name[ ..] ) . ok ( ) . expect ( "Failed to drop database from server." ) ;
50
+ client. drop_database ( & name[ ..] ) . expect ( "Failed to drop database from server." ) ;
51
51
}
52
52
}
53
53
54
54
let client1 = client. clone ( ) ;
55
55
let client2 = client. clone ( ) ;
56
56
57
- let base_results = client. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
57
+ let base_results = client. database_names ( ) . expect ( "Failed to execute database_names." ) ;
58
58
assert_eq ! ( 1 , base_results. len( ) ) ;
59
59
assert_eq ! ( "local" , base_results[ 0 ] ) ;
60
60
61
61
let child1 = thread:: spawn ( move || {
62
62
let db = client1. db ( "concurrent_db" ) ;
63
63
db. collection ( "test1" ) . insert_one ( bson:: Document :: new ( ) , None )
64
- . ok ( ) . expect ( "Failed to insert placeholder document into collection" ) ;
65
- let results = client1. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
64
+ . expect ( "Failed to insert placeholder document into collection" ) ;
65
+ let results = client1. database_names ( ) . expect ( "Failed to execute database_names." ) ;
66
66
assert ! ( results. contains( & "concurrent_db" . to_owned( ) ) ) ;
67
67
} ) ;
68
68
69
69
let child2 = thread:: spawn ( move || {
70
70
let db = client2. db ( "concurrent_db_2" ) ;
71
71
db. collection ( "test2" ) . insert_one ( bson:: Document :: new ( ) , None )
72
- . ok ( ) . expect ( "Failed to insert placeholder document into collection" ) ;
73
- let results = client2. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
72
+ . expect ( "Failed to insert placeholder document into collection" ) ;
73
+ let results = client2. database_names ( ) . expect ( "Failed to execute database_names." ) ;
74
74
assert ! ( results. contains( & "concurrent_db_2" . to_owned( ) ) ) ;
75
75
} ) ;
76
76
77
77
let _ = child1. join ( ) ;
78
78
let _ = child2. join ( ) ;
79
79
80
80
// Check new dbs
81
- let results = client. database_names ( ) . ok ( ) . expect ( "Failed to execute database_names." ) ;
81
+ let results = client. database_names ( ) . expect ( "Failed to execute database_names." ) ;
82
82
assert_eq ! ( 3 , results. len( ) ) ;
83
83
assert ! ( results. contains( & "local" . to_owned( ) ) ) ;
84
84
assert ! ( results. contains( & "concurrent_db" . to_owned( ) ) ) ;
0 commit comments