@@ -29,8 +29,8 @@ fn create_delete_scopes_collections() {
29
29
assert ! ( db. scope( DEFAULT_NAME . to_string( ) ) . unwrap( ) . is_some( ) ) ;
30
30
assert ! ( db. scope( unknown. clone( ) ) . unwrap( ) . is_none( ) ) ;
31
31
assert_eq ! (
32
- db. default_scope( ) . unwrap( ) ,
33
- db. scope( DEFAULT_NAME . to_string( ) ) . unwrap( ) . unwrap( )
32
+ db. default_scope( ) . unwrap( ) . name ( ) ,
33
+ db. scope( DEFAULT_NAME . to_string( ) ) . unwrap( ) . unwrap( ) . name ( )
34
34
) ;
35
35
36
36
// Get collection
@@ -46,10 +46,11 @@ fn create_delete_scopes_collections() {
46
46
. collection( DEFAULT_NAME . to_string( ) , unknown. clone( ) )
47
47
. is_err( ) ) ; // Invalid scope => Err
48
48
assert_eq ! (
49
- db. default_collection( ) . unwrap( ) . unwrap( ) ,
49
+ db. default_collection( ) . unwrap( ) . unwrap( ) . full_name ( ) ,
50
50
db. collection( DEFAULT_NAME . to_string( ) , DEFAULT_NAME . to_string( ) )
51
51
. unwrap( )
52
52
. unwrap( )
53
+ . full_name( )
53
54
) ;
54
55
55
56
// Add collection in default scope
@@ -61,13 +62,15 @@ fn create_delete_scopes_collections() {
61
62
assert_eq ! (
62
63
db. collection( new_collection_1. clone( ) , DEFAULT_NAME . to_string( ) )
63
64
. unwrap( )
64
- . unwrap( ) ,
65
- c1_default_scope
65
+ . unwrap( )
66
+ . full_name( ) ,
67
+ c1_default_scope. full_name( )
66
68
) ;
67
69
assert_eq ! (
68
70
db. create_collection( new_collection_1. clone( ) , DEFAULT_NAME . to_string( ) )
69
- . unwrap( ) ,
70
- c1_default_scope
71
+ . unwrap( )
72
+ . full_name( ) ,
73
+ c1_default_scope. full_name( )
71
74
) ;
72
75
73
76
assert_eq ! (
@@ -85,13 +88,15 @@ fn create_delete_scopes_collections() {
85
88
assert_eq ! (
86
89
db. collection( new_collection_2. clone( ) , new_scope. clone( ) )
87
90
. unwrap( )
88
- . unwrap( ) ,
89
- c2_new_scope
91
+ . unwrap( )
92
+ . full_name( ) ,
93
+ c2_new_scope. full_name( )
90
94
) ;
91
95
assert_eq ! (
92
96
db. create_collection( new_collection_2. clone( ) , new_scope. clone( ) )
93
- . unwrap( ) ,
94
- c2_new_scope
97
+ . unwrap( )
98
+ . full_name( ) ,
99
+ c2_new_scope. full_name( )
95
100
) ;
96
101
97
102
assert_eq ! (
@@ -158,8 +163,9 @@ fn collections_accessors() {
158
163
assert_eq ! (
159
164
db. collection( new_collection_1. clone( ) , DEFAULT_NAME . to_string( ) )
160
165
. unwrap( )
161
- . unwrap( ) ,
162
- c1_default_scope
166
+ . unwrap( )
167
+ . full_name( ) ,
168
+ c1_default_scope. full_name( )
163
169
) ;
164
170
165
171
let c2_new_scope = db
@@ -168,8 +174,9 @@ fn collections_accessors() {
168
174
assert_eq ! (
169
175
db. collection( new_collection_2. clone( ) , new_scope. clone( ) )
170
176
. unwrap( )
171
- . unwrap( ) ,
172
- c2_new_scope
177
+ . unwrap( )
178
+ . full_name( ) ,
179
+ c2_new_scope. full_name( )
173
180
) ;
174
181
175
182
let c1_new_scope = db
@@ -178,23 +185,43 @@ fn collections_accessors() {
178
185
assert_eq ! (
179
186
db. collection( new_collection_1. clone( ) , new_scope. clone( ) )
180
187
. unwrap( )
181
- . unwrap( ) ,
182
- c1_new_scope
188
+ . unwrap( )
189
+ . full_name( ) ,
190
+ c1_new_scope. full_name( )
183
191
) ;
184
192
185
193
let default_scope = db. scope ( DEFAULT_NAME . to_string ( ) ) . unwrap ( ) . unwrap ( ) ;
186
194
let new_actual_scope = db. scope ( new_scope. clone ( ) ) . unwrap ( ) . unwrap ( ) ;
187
195
188
196
// Scope
189
- assert_eq ! ( c1_default_scope. scope( ) , default_scope) ;
190
- assert_eq ! ( c2_new_scope. scope( ) , new_actual_scope) ;
191
- assert_eq ! ( c1_new_scope. scope( ) , new_actual_scope) ;
197
+ assert_eq ! ( c1_default_scope. scope( ) . name ( ) , default_scope. name ( ) ) ;
198
+ assert_eq ! ( c2_new_scope. scope( ) . name ( ) , new_actual_scope. name ( ) ) ;
199
+ assert_eq ! ( c1_new_scope. scope( ) . name ( ) , new_actual_scope. name ( ) ) ;
192
200
193
201
// Name
194
202
assert_eq ! ( c1_default_scope. name( ) , new_collection_1. clone( ) ) ;
195
203
assert_eq ! ( c2_new_scope. name( ) , new_collection_2. clone( ) ) ;
196
204
assert_eq ! ( c1_new_scope. name( ) , new_collection_1. clone( ) ) ;
197
205
206
+ // Full name
207
+ assert_eq ! (
208
+ c1_default_scope. full_name( ) ,
209
+ format!( "{}.{}" , DEFAULT_NAME , new_collection_1)
210
+ ) ;
211
+ assert_eq ! (
212
+ c2_new_scope. full_name( ) ,
213
+ format!( "{}.{}" , new_scope, new_collection_2)
214
+ ) ;
215
+ assert_eq ! (
216
+ c1_new_scope. full_name( ) ,
217
+ format!( "{}.{}" , new_scope, new_collection_1)
218
+ ) ;
219
+
220
+ // Database
221
+ assert_eq ! ( c1_default_scope. database( ) . get_ref( ) , db. get_ref( ) ) ;
222
+ assert_eq ! ( c2_new_scope. database( ) . get_ref( ) , db. get_ref( ) ) ;
223
+ assert_eq ! ( c1_new_scope. database( ) . get_ref( ) , db. get_ref( ) ) ;
224
+
198
225
// Count
199
226
assert_eq ! ( c1_default_scope. count( ) , 0 ) ;
200
227
assert_eq ! ( c2_new_scope. count( ) , 0 ) ;
@@ -216,8 +243,9 @@ fn scope_accessors() {
216
243
assert_eq ! (
217
244
db. collection( new_collection_1. clone( ) , DEFAULT_NAME . to_string( ) )
218
245
. unwrap( )
219
- . unwrap( ) ,
220
- c1_default_scope
246
+ . unwrap( )
247
+ . full_name( ) ,
248
+ c1_default_scope. full_name( )
221
249
) ;
222
250
223
251
let c2_new_scope = db
@@ -226,8 +254,9 @@ fn scope_accessors() {
226
254
assert_eq ! (
227
255
db. collection( new_collection_2. clone( ) , new_scope. clone( ) )
228
256
. unwrap( )
229
- . unwrap( ) ,
230
- c2_new_scope
257
+ . unwrap( )
258
+ . full_name( ) ,
259
+ c2_new_scope. full_name( )
231
260
) ;
232
261
233
262
let c1_new_scope = db
@@ -236,8 +265,9 @@ fn scope_accessors() {
236
265
assert_eq ! (
237
266
db. collection( new_collection_1. clone( ) , new_scope. clone( ) )
238
267
. unwrap( )
239
- . unwrap( ) ,
240
- c1_new_scope
268
+ . unwrap( )
269
+ . full_name( ) ,
270
+ c1_new_scope. full_name( )
241
271
) ;
242
272
243
273
let default_scope = db. scope ( DEFAULT_NAME . to_string ( ) ) . unwrap ( ) . unwrap ( ) ;
@@ -247,6 +277,20 @@ fn scope_accessors() {
247
277
assert_eq ! ( default_scope. name( ) , DEFAULT_NAME . to_string( ) ) ;
248
278
assert_eq ! ( new_actual_scope. name( ) , new_scope. clone( ) ) ;
249
279
280
+ // Database
281
+ assert_eq ! (
282
+ db. get_ref( ) ,
283
+ db. default_scope( ) . unwrap( ) . database( ) . get_ref( )
284
+ ) ;
285
+ assert_eq ! (
286
+ db. get_ref( ) ,
287
+ db. scope( new_scope. clone( ) )
288
+ . unwrap( )
289
+ . unwrap( )
290
+ . database( )
291
+ . get_ref( )
292
+ ) ;
293
+
250
294
// Collections
251
295
assert_eq ! (
252
296
default_scope. collection_names( ) . unwrap( ) ,
@@ -266,22 +310,25 @@ fn scope_accessors() {
266
310
default_scope
267
311
. collection( new_collection_1. clone( ) )
268
312
. unwrap( )
269
- . unwrap( ) ,
270
- c1_default_scope
313
+ . unwrap( )
314
+ . full_name( ) ,
315
+ c1_default_scope. full_name( )
271
316
) ;
272
317
assert_eq ! (
273
318
new_actual_scope
274
319
. collection( new_collection_2. clone( ) )
275
320
. unwrap( )
276
- . unwrap( ) ,
277
- c2_new_scope
321
+ . unwrap( )
322
+ . full_name( ) ,
323
+ c2_new_scope. full_name( )
278
324
) ;
279
325
assert_eq ! (
280
326
new_actual_scope
281
327
. collection( new_collection_1. clone( ) )
282
328
. unwrap( )
283
- . unwrap( ) ,
284
- c1_new_scope
329
+ . unwrap( )
330
+ . full_name( ) ,
331
+ c1_new_scope. full_name( )
285
332
) ;
286
333
} ) ;
287
334
}
0 commit comments