1
1
use azure_data_cosmos:: resources:: collection:: * ;
2
2
use futures:: StreamExt ;
3
+ use tracing:: { debug, info} ;
3
4
4
5
mod setup_mock;
5
6
6
7
#[ tokio:: test]
7
8
async fn collection_operations ( ) -> azure_core:: Result < ( ) > {
8
- env_logger :: init ( ) ;
9
+ tracing_subscriber :: fmt ( ) . init ( ) ;
9
10
10
11
let client = setup_mock:: initialize ( "collection_operations" ) ?;
11
12
let database_name = "test-collection-operations" ;
12
13
13
- log :: info!( "Creating a database with name '{}'..." , database_name) ;
14
+ info ! ( "Creating a database with name '{}'..." , database_name) ;
14
15
client. create_database ( database_name) . await ?;
15
- log :: info!( "Successfully created a database" ) ;
16
+ info ! ( "Successfully created a database" ) ;
16
17
17
18
// create collection!
18
19
let database = client. database_client ( database_name) ;
19
20
20
21
let collection_name = "sample_collection" ;
21
- log :: info!( "Creating a collection with name '{}'..." , collection_name) ;
22
+ info ! ( "Creating a collection with name '{}'..." , collection_name) ;
22
23
23
24
let create_collection_response = database. create_collection ( collection_name, "/id" ) . await ?;
24
25
25
26
assert_eq ! ( create_collection_response. collection. id, collection_name) ;
26
27
27
- log :: info!( "Successfully created a collection" ) ;
28
- log :: debug!(
28
+ info ! ( "Successfully created a collection" ) ;
29
+ debug ! (
29
30
"The create_collection response: {:#?}" ,
30
31
create_collection_response
31
32
) ;
@@ -37,8 +38,8 @@ async fn collection_operations() -> azure_core::Result<()> {
37
38
38
39
assert_eq ! ( get_collection. collection. id, collection_name) ;
39
40
40
- log :: info!( "Successfully got a collection" ) ;
41
- log :: debug!( "The get_collection response: {:#?}" , get_collection) ;
41
+ info ! ( "Successfully got a collection" ) ;
42
+ debug ! ( "The get_collection response: {:#?}" , get_collection) ;
42
43
43
44
let collections = database
44
45
. list_collections ( )
@@ -99,24 +100,24 @@ async fn collection_operations() -> azure_core::Result<()> {
99
100
"/\" excludeme\" /?"
100
101
) ;
101
102
102
- log :: info!( "Successfully replaced collection" ) ;
103
- log :: debug!(
103
+ info ! ( "Successfully replaced collection" ) ;
104
+ debug ! (
104
105
"The replace_collection response: {:#?}" ,
105
106
replace_collection_response
106
107
) ;
107
108
108
109
// delete collection!
109
110
let delete_collection_response = collection. delete_collection ( ) . await ?;
110
111
111
- log :: info!( "Successfully deleted collection" ) ;
112
- log :: debug!(
112
+ info ! ( "Successfully deleted collection" ) ;
113
+ debug ! (
113
114
"The delete_collection response: {:#?}" ,
114
115
delete_collection_response
115
116
) ;
116
117
117
118
// delete database
118
119
database. delete_database ( ) . await ?;
119
- log :: info!( "Successfully deleted database" ) ;
120
+ info ! ( "Successfully deleted database" ) ;
120
121
121
122
Ok ( ( ) )
122
123
}
0 commit comments