From e6bb26f81eb9ae5af531c2a329bbc61bcc137758 Mon Sep 17 00:00:00 2001 From: yoshidan Date: Tue, 5 Dec 2023 09:09:26 +0900 Subject: [PATCH 1/2] change test --- .../src/http/bigquery_tabledata_client.rs | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/bigquery/src/http/bigquery_tabledata_client.rs b/bigquery/src/http/bigquery_tabledata_client.rs index 1f349310..993f9d5c 100644 --- a/bigquery/src/http/bigquery_tabledata_client.rs +++ b/bigquery/src/http/bigquery_tabledata_client.rs @@ -93,7 +93,7 @@ mod test { #[tokio::test] #[serial] - pub async fn table_data() { + pub async fn insert_all() { let dataset = dataset_name("table"); let (client, project) = create_client().await; let client = Arc::new(client); @@ -141,24 +141,37 @@ mod test { .unwrap(); assert!(res2.insert_errors.is_none()); + table_client + .delete(ref1.project_id.as_str(), ref1.dataset_id.as_str(), ref1.table_id.as_str()) + .await + .unwrap(); + } + + #[tokio::test] + #[serial] + pub async fn read_all() { + let dataset = dataset_name("job"); + let (client, project) = create_client().await; + let client = Arc::new(client); + let client = BigqueryTabledataClient::new(client.clone()); + // fetch let mut fetch_request = FetchDataRequest { - max_results: Some(1), + max_results: Some(500), ..Default::default() }; let mut data: Vec = vec![]; loop { let result = client .read( - ref1.project_id.as_str(), - ref1.dataset_id.as_str(), - ref1.table_id.as_str(), + project.as_str(), + dataset.as_str(), + "reading_data", &fetch_request, ) .await .unwrap(); if let Some(rows) = result.rows { - println!("{:?}", rows); data.extend(rows); } if result.page_token.is_none() { @@ -166,10 +179,6 @@ mod test { } fetch_request.page_token = result.page_token } - assert_eq!(data.len(), 2, "{:?}", data.pop()); - table_client - .delete(ref1.project_id.as_str(), ref1.dataset_id.as_str(), ref1.table_id.as_str()) - .await - .unwrap(); + assert_eq!(data.len(), 1000, "{:?}", data.pop()); } } From 8e831890c8ebbaea0fca919ef112629b79377088 Mon Sep 17 00:00:00 2001 From: yoshidan Date: Tue, 5 Dec 2023 10:06:13 +0900 Subject: [PATCH 2/2] fmt --- bigquery/src/http/bigquery_tabledata_client.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bigquery/src/http/bigquery_tabledata_client.rs b/bigquery/src/http/bigquery_tabledata_client.rs index 993f9d5c..26f866f2 100644 --- a/bigquery/src/http/bigquery_tabledata_client.rs +++ b/bigquery/src/http/bigquery_tabledata_client.rs @@ -163,12 +163,7 @@ mod test { let mut data: Vec = vec![]; loop { let result = client - .read( - project.as_str(), - dataset.as_str(), - "reading_data", - &fetch_request, - ) + .read(project.as_str(), dataset.as_str(), "reading_data", &fetch_request) .await .unwrap(); if let Some(rows) = result.rows {