11#![ cfg( all( test, feature = "test_e2e" ) ) ]
22use azure_core:: Context ;
3- use azure_data_cosmos:: prelude:: {
4- CreateDocumentBuilder , DeleteDatabaseBuilder , GetDocumentOptions ,
5- } ;
3+ use azure_data_cosmos:: prelude:: GetDocumentOptions ;
64use serde:: { Deserialize , Serialize } ;
75
86mod setup;
@@ -11,17 +9,17 @@ use azure_core::prelude::*;
119use azure_data_cosmos:: prelude:: * ;
1210use collection:: * ;
1311
14- #[ derive( Serialize , Deserialize , Debug , PartialEq ) ]
12+ #[ derive( Clone , Serialize , Deserialize , Debug , PartialEq ) ]
1513struct MyDocument {
1614 id : String ,
1715 hello : u32 ,
1816}
1917
20- impl < ' a > azure_data_cosmos:: CosmosEntity < ' a > for MyDocument {
21- type Entity = & ' a str ;
18+ impl azure_data_cosmos:: CosmosEntity for MyDocument {
19+ type Entity = String ;
2220
23- fn partition_key ( & ' a self ) -> Self :: Entity {
24- self . id . as_ref ( )
21+ fn partition_key ( & self ) -> Self :: Entity {
22+ self . id . clone ( )
2523 }
2624}
2725
@@ -49,11 +47,11 @@ async fn create_and_delete_document() {
4947 excluded_paths : vec ! [ ] ,
5048 } ;
5149
52- let options = CreateCollectionOptions :: new ( "/id" )
53- . offer ( Offer :: Throughput ( 400 ) )
54- . indexing_policy ( indexing_policy) ;
5550 database_client
56- . create_collection ( Context :: new ( ) , COLLECTION_NAME , options)
51+ . create_collection ( COLLECTION_NAME , "/id" )
52+ . offer ( Offer :: Throughput ( 400 ) )
53+ . indexing_policy ( indexing_policy)
54+ . into_future ( )
5755 . await
5856 . unwrap ( ) ;
5957
@@ -67,7 +65,8 @@ async fn create_and_delete_document() {
6765 hello : 42 ,
6866 } ;
6967 collection_client
70- . create_document ( Context :: new ( ) , & document_data, CreateDocumentOptions :: new ( ) )
68+ . create_document ( document_data. clone ( ) )
69+ . into_future ( )
7170 . await
7271 . unwrap ( ) ;
7372
@@ -98,7 +97,8 @@ async fn create_and_delete_document() {
9897
9998 // delete document
10099 document_client
101- . delete_document ( Context :: new ( ) , DeleteDocumentOptions :: new ( ) )
100+ . delete_document ( )
101+ . into_future ( )
102102 . await
103103 . unwrap ( ) ;
104104
@@ -111,7 +111,8 @@ async fn create_and_delete_document() {
111111 assert ! ( documents. len( ) == 0 ) ;
112112
113113 database_client
114- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
114+ . delete_database ( )
115+ . into_future ( )
115116 . await
116117 . unwrap ( ) ;
117118}
@@ -139,11 +140,11 @@ async fn query_documents() {
139140 excluded_paths : vec ! [ ] ,
140141 } ;
141142
142- let options = CreateCollectionOptions :: new ( "/id" )
143- . indexing_policy ( indexing_policy)
144- . offer ( Offer :: S2 ) ;
145143 database_client
146- . create_collection ( Context :: new ( ) , COLLECTION_NAME , options)
144+ . create_collection ( COLLECTION_NAME , "/id" )
145+ . indexing_policy ( indexing_policy)
146+ . offer ( Offer :: S2 )
147+ . into_future ( )
147148 . await
148149 . unwrap ( ) ;
149150
@@ -157,7 +158,8 @@ async fn query_documents() {
157158 hello : 42 ,
158159 } ;
159160 collection_client
160- . create_document ( Context :: new ( ) , & document_data, CreateDocumentOptions :: new ( ) )
161+ . create_document ( document_data. clone ( ) )
162+ . into_future ( )
161163 . await
162164 . unwrap ( ) ;
163165
@@ -185,7 +187,8 @@ async fn query_documents() {
185187 assert_eq ! ( query_result[ 0 ] . result, document_data) ;
186188
187189 database_client
188- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
190+ . delete_database ( )
191+ . into_future ( )
189192 . await
190193 . unwrap ( ) ;
191194}
@@ -213,11 +216,11 @@ async fn replace_document() {
213216 excluded_paths : vec ! [ ] ,
214217 } ;
215218
216- let options = CreateCollectionOptions :: new ( "/id" )
217- . indexing_policy ( indexing_policy)
218- . offer ( Offer :: S2 ) ;
219219 database_client
220- . create_collection ( Context :: new ( ) , COLLECTION_NAME , options)
220+ . create_collection ( COLLECTION_NAME , "/id" )
221+ . indexing_policy ( indexing_policy)
222+ . offer ( Offer :: S2 )
223+ . into_future ( )
221224 . await
222225 . unwrap ( ) ;
223226
@@ -231,7 +234,8 @@ async fn replace_document() {
231234 hello : 42 ,
232235 } ;
233236 collection_client
234- . create_document ( Context :: new ( ) , & document_data, CreateDocumentOptions :: new ( ) )
237+ . create_document ( document_data. clone ( ) )
238+ . into_future ( )
235239 . await
236240 . unwrap ( ) ;
237241
@@ -279,7 +283,8 @@ async fn replace_document() {
279283 }
280284
281285 database_client
282- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
286+ . delete_database ( )
287+ . into_future ( )
283288 . await
284289 . unwrap ( ) ;
285290}
0 commit comments