Skip to content

Commit

Permalink
fix(core): make client scheme public
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Apr 7, 2024
1 parent b01f9b8 commit 14b5989
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ static VERSION: Lazy<String> = Lazy::new(|| {
#[derive(Clone)]
pub struct APIClient {
pub cli: HttpClient,
scheme: String,
endpoint: Url,
pub scheme: String,
pub host: String,
pub port: u16,

endpoint: Url,

auth: Arc<dyn Auth>,

tenant: Option<String>,
Expand Down
19 changes: 14 additions & 5 deletions driver/tests/driver/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ async fn prepare_client(presigned: bool) -> Option<Client> {
Some(client)
}

async fn prepare_table(client: &Client) -> String {
async fn prepare_table(client: &Client, prefix: &str) -> String {
let conn = client.get_conn().await.unwrap();
let table = format!("books_{}", Utc::now().format("%Y%m%d%H%M%S%9f"));
let table = format!("books_{}_{}", prefix, Utc::now().format("%Y%m%d%H%M%S%9f"));
let sql = format!(
"CREATE TABLE `{}` (
title VARCHAR NULL,
Expand Down Expand Up @@ -118,29 +118,38 @@ async fn check_result(table: &str, client: &Client) {
conn.exec(&sql).await.unwrap();
}

async fn cleanup(client: &Client, table: &str) {
let conn = client.get_conn().await.unwrap();
let sql = format!("DROP TABLE `{}`;", table);
conn.exec(&sql).await.unwrap();
}

#[tokio::test]
async fn load_csv_with_presign() {
if let Some(client) = prepare_client(true).await {
let table = prepare_table(&client).await;
let table = prepare_table(&client, "load_csv_with_presign").await;
prepare_data_with_file(&table, "csv", &client).await;
check_result(&table, &client).await;
cleanup(&client, &table).await;
}
}

#[tokio::test]
async fn load_csv_without_presign() {
if let Some(client) = prepare_client(false).await {
let table = prepare_table(&client).await;
let table = prepare_table(&client, "load_csv_without_presign").await;
prepare_data_with_file(&table, "csv", &client).await;
check_result(&table, &client).await;
cleanup(&client, &table).await;
}
}

#[tokio::test]
async fn stream_load_with_presign() {
if let Some(client) = prepare_client(true).await {
let table = prepare_table(&client).await;
let table = prepare_table(&client, "stream_load_with_presign").await;
prepare_data(&table, &client).await;
check_result(&table, &client).await;
cleanup(&client, &table).await;
}
}

0 comments on commit 14b5989

Please sign in to comment.