1
1
#![ cfg( all( test, feature = "test_e2e" ) ) ]
2
2
use azure_core:: Context ;
3
- use azure_data_cosmos:: prelude:: {
4
- CreateDocumentBuilder , DeleteDatabaseBuilder , GetDocumentOptions ,
5
- } ;
3
+ use azure_data_cosmos:: prelude:: GetDocumentOptions ;
6
4
use serde:: { Deserialize , Serialize } ;
7
5
8
6
mod setup;
@@ -11,17 +9,17 @@ use azure_core::prelude::*;
11
9
use azure_data_cosmos:: prelude:: * ;
12
10
use collection:: * ;
13
11
14
- #[ derive( Serialize , Deserialize , Debug , PartialEq ) ]
12
+ #[ derive( Clone , Serialize , Deserialize , Debug , PartialEq ) ]
15
13
struct MyDocument {
16
14
id : String ,
17
15
hello : u32 ,
18
16
}
19
17
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 ;
22
20
23
- fn partition_key ( & ' a self ) -> Self :: Entity {
24
- self . id . as_ref ( )
21
+ fn partition_key ( & self ) -> Self :: Entity {
22
+ self . id . clone ( )
25
23
}
26
24
}
27
25
@@ -49,11 +47,11 @@ async fn create_and_delete_document() {
49
47
excluded_paths : vec ! [ ] ,
50
48
} ;
51
49
52
- let options = CreateCollectionOptions :: new ( "/id" )
53
- . offer ( Offer :: Throughput ( 400 ) )
54
- . indexing_policy ( indexing_policy) ;
55
50
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 ( )
57
55
. await
58
56
. unwrap ( ) ;
59
57
@@ -67,7 +65,8 @@ async fn create_and_delete_document() {
67
65
hello : 42 ,
68
66
} ;
69
67
collection_client
70
- . create_document ( Context :: new ( ) , & document_data, CreateDocumentOptions :: new ( ) )
68
+ . create_document ( document_data. clone ( ) )
69
+ . into_future ( )
71
70
. await
72
71
. unwrap ( ) ;
73
72
@@ -98,7 +97,8 @@ async fn create_and_delete_document() {
98
97
99
98
// delete document
100
99
document_client
101
- . delete_document ( Context :: new ( ) , DeleteDocumentOptions :: new ( ) )
100
+ . delete_document ( )
101
+ . into_future ( )
102
102
. await
103
103
. unwrap ( ) ;
104
104
@@ -111,7 +111,8 @@ async fn create_and_delete_document() {
111
111
assert ! ( documents. len( ) == 0 ) ;
112
112
113
113
database_client
114
- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
114
+ . delete_database ( )
115
+ . into_future ( )
115
116
. await
116
117
. unwrap ( ) ;
117
118
}
@@ -139,11 +140,11 @@ async fn query_documents() {
139
140
excluded_paths : vec ! [ ] ,
140
141
} ;
141
142
142
- let options = CreateCollectionOptions :: new ( "/id" )
143
- . indexing_policy ( indexing_policy)
144
- . offer ( Offer :: S2 ) ;
145
143
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 ( )
147
148
. await
148
149
. unwrap ( ) ;
149
150
@@ -157,7 +158,8 @@ async fn query_documents() {
157
158
hello : 42 ,
158
159
} ;
159
160
collection_client
160
- . create_document ( Context :: new ( ) , & document_data, CreateDocumentOptions :: new ( ) )
161
+ . create_document ( document_data. clone ( ) )
162
+ . into_future ( )
161
163
. await
162
164
. unwrap ( ) ;
163
165
@@ -185,7 +187,8 @@ async fn query_documents() {
185
187
assert_eq ! ( query_result[ 0 ] . result, document_data) ;
186
188
187
189
database_client
188
- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
190
+ . delete_database ( )
191
+ . into_future ( )
189
192
. await
190
193
. unwrap ( ) ;
191
194
}
@@ -213,11 +216,11 @@ async fn replace_document() {
213
216
excluded_paths : vec ! [ ] ,
214
217
} ;
215
218
216
- let options = CreateCollectionOptions :: new ( "/id" )
217
- . indexing_policy ( indexing_policy)
218
- . offer ( Offer :: S2 ) ;
219
219
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 ( )
221
224
. await
222
225
. unwrap ( ) ;
223
226
@@ -231,7 +234,8 @@ async fn replace_document() {
231
234
hello : 42 ,
232
235
} ;
233
236
collection_client
234
- . create_document ( Context :: new ( ) , & document_data, CreateDocumentOptions :: new ( ) )
237
+ . create_document ( document_data. clone ( ) )
238
+ . into_future ( )
235
239
. await
236
240
. unwrap ( ) ;
237
241
@@ -279,7 +283,8 @@ async fn replace_document() {
279
283
}
280
284
281
285
database_client
282
- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
286
+ . delete_database ( )
287
+ . into_future ( )
283
288
. await
284
289
. unwrap ( ) ;
285
290
}
0 commit comments