Skip to content

Commit d78e189

Browse files
committed
convert missing tests
1 parent beab9aa commit d78e189

18 files changed

+68
-329
lines changed

sdk/data_cosmos/examples/create_delete_database.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
4444

4545
// create collection!
4646
{
47-
let db_client = client.database(database_name.clone());
48-
let create_collection_response = db_client
47+
let database = client.database(database_name.clone());
48+
let create_collection_response = database
4949
.create_collection("panzadoro", "/id")
5050
.into_future()
5151
.await?;
@@ -55,12 +55,12 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
5555
create_collection_response
5656
);
5757

58-
let db_collection = db_client.collection("panzadoro");
58+
let db_collection = database.collection("panzadoro");
5959

6060
let get_collection_response = db_collection.get_collection().into_future().await?;
6161
println!("get_collection_response == {:#?}", get_collection_response);
6262

63-
let mut stream = db_client.list_collections().into_stream();
63+
let mut stream = database.list_collections().into_stream();
6464
while let Some(res) = stream.next().await {
6565
let res = res?;
6666
println!("res == {:#?}", res);

sdk/data_cosmos/examples/permission_00.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
3333

3434
let database = client.database(database_name);
3535
let collection = database.collection(collection_name);
36-
let collection2_client = database.collection(collection_name2);
36+
let collection2 = database.collection(collection_name2);
3737
let user = database.user(user_name);
3838

3939
let get_database_response = database.get_database().into_future().await?;
@@ -42,7 +42,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
4242
let get_collection_response = collection.get_collection().into_future().await?;
4343
println!("get_collection_response == {:#?}", get_collection_response);
4444

45-
let get_collection2_response = collection2_client.get_collection().into_future().await?;
45+
let get_collection2_response = collection2.get_collection().into_future().await?;
4646
println!(
4747
"get_collection2_response == {:#?}",
4848
get_collection2_response

sdk/data_cosmos/src/clients/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! // Create an http client, then a `CosmosClient`, and then a `DatabaseClient`
1616
//! let client = CosmosClient::new(account, authorization_token, CosmosOptions::default());
17-
//! let client = client.into_database(database_name);
17+
//! let client = client.database(database_name);
1818
//! ```
1919
2020
mod attachment;

sdk/data_cosmos/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
6464
let client = CosmosClient::new(account.clone(), authorization_token, CosmosOptions::default());
6565
6666
// We know the database so we can obtain a database client.
67-
let database = client.into_database(database_name);
67+
let database = client.database(database_name);
6868
// We know the collection so we can obtain a collection client.
69-
let collection = database.into_collection(collection_name);
69+
let collection = database.collection(collection_name);
7070
7171
// Insert 10 documents
7272
println!("Inserting 10 documents...");

sdk/data_cosmos/src/requests/execute_stored_procedure_builder.rs

Lines changed: 0 additions & 90 deletions
This file was deleted.

sdk/data_cosmos/src/requests/get_partition_key_ranges_builder.rs

Lines changed: 0 additions & 68 deletions
This file was deleted.

sdk/data_cosmos/src/requests/replace_reference_attachment_builder.rs

Lines changed: 0 additions & 89 deletions
This file was deleted.

sdk/data_cosmos/tests/attachment_00.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
4141
.await
4242
.unwrap();
4343

44-
let database = client.into_database(DATABASE_NAME);
44+
let database = client.database(DATABASE_NAME);
4545

4646
// create a temp collection
4747
let _create_collection_response = {
@@ -72,7 +72,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
7272
.unwrap()
7373
};
7474

75-
let collection = database.clone().into_collection(COLLECTION_NAME);
75+
let collection = database.collection(COLLECTION_NAME);
7676

7777
let id = format!("unique_id{}", 100);
7878

@@ -90,7 +90,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
9090
.await?
9191
.into();
9292

93-
let document = collection.into_document(id.clone(), &doc.id)?;
93+
let document = collection.document(id.clone(), &doc.id)?;
9494

9595
// list attachments, there must be none.
9696
let ret = document
@@ -103,7 +103,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
103103
assert_eq!(0, ret.attachments.len());
104104

105105
// create reference attachment
106-
let attachment = document.into_attachment("reference");
106+
let attachment = document.attachment("reference");
107107
let resp = attachment
108108
.create_attachment("https://www.bing.com", "image/jpeg")
109109
.consistency_level(&ret)
@@ -118,7 +118,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
118118
.await?;
119119

120120
// create slug attachment
121-
let attachment = document.into_attachment("slug");
121+
let attachment = document.attachment("slug");
122122
let resp = attachment
123123
.create_slug("something cool here".into())
124124
.consistency_level(&resp)
@@ -138,8 +138,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
138138

139139
// get reference attachment, it must have the updated media link
140140
let reference_attachment = document
141-
.clone()
142-
.into_attachment("reference")
141+
.attachment("reference")
143142
.get()
144143
.consistency_level(&ret)
145144
.into_future()
@@ -152,8 +151,7 @@ async fn attachment() -> Result<(), azure_data_cosmos::Error> {
152151
// get slug attachment, it must have the text/plain content type
153152
println!("getting slug attachment");
154153
let slug_attachment = document
155-
.clone()
156-
.into_attachment("slug")
154+
.attachment("slug")
157155
.get()
158156
.consistency_level(&reference_attachment)
159157
.into_future()

0 commit comments

Comments
 (0)