2021-03-09 19:08:55 +00:00
|
|
|
use crate::common::server_fixture::ServerFixture;
|
|
|
|
use crate::Scenario;
|
2021-01-27 21:20:52 +00:00
|
|
|
|
|
|
|
pub async fn test(
|
2021-03-09 19:08:55 +00:00
|
|
|
server_fixture: &ServerFixture,
|
2021-01-27 21:20:52 +00:00
|
|
|
scenario: &Scenario,
|
|
|
|
sql_query: &str,
|
|
|
|
expected_read_data: &[String],
|
|
|
|
) {
|
2021-03-09 19:08:55 +00:00
|
|
|
let client = reqwest::Client::new();
|
2021-02-26 11:43:03 +00:00
|
|
|
let db_name = format!("{}_{}", scenario.org_id_str(), scenario.bucket_id_str());
|
|
|
|
let path = format!("/databases/{}/query", db_name);
|
2021-03-09 19:08:55 +00:00
|
|
|
let url = format!("{}{}", server_fixture.iox_api_v1_base(), path);
|
|
|
|
let lines: Vec<_> = client
|
2021-01-27 21:20:52 +00:00
|
|
|
.get(&url)
|
2021-02-26 11:43:03 +00:00
|
|
|
.query(&[("q", sql_query)])
|
2021-01-27 21:20:52 +00:00
|
|
|
.send()
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.text()
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.trim()
|
|
|
|
.split('\n')
|
|
|
|
.map(str::to_string)
|
|
|
|
.collect();
|
2021-03-09 19:08:55 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
lines, expected_read_data,
|
|
|
|
"Actual:\n{:#?}\nExpected:\n{:#?}",
|
|
|
|
lines, expected_read_data
|
|
|
|
);
|
2021-01-27 21:20:52 +00:00
|
|
|
}
|