refactor: Move some helper functions after the main test
@@ -48,46 +48,6 @@ const TOKEN: &str = "InfluxDB IOx doesn't have authentication yet";
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
type Result<T, E = Error> = std::result::Result<T, E>;
-async fn read_data_as_sql(
- client: &reqwest::Client,
- path: &str,
- org_id: &str,
- bucket_id: &str,
- sql_query: &str,
-) -> Vec<String> {
- let url = format!("{}{}", API_BASE, path);
- let lines = client
- .get(&url)
- .query(&[
- ("bucket", bucket_id),
- ("org", org_id),
- ("sql_query", sql_query),
- ])
- .send()
- .await
- .unwrap()
- .text()
- .await
- .unwrap()
- .trim()
- .split('\n')
- .map(str::to_string)
- .collect();
- lines
-}
-
-async fn write_data(
- client: &influxdb2_client::Client,
- org_id: &str,
- bucket_id: &str,
- points: Vec<influxdb2_client::DataPoint>,
-) -> Result<()> {
- client
- .write(org_id, bucket_id, stream::iter(points))
- .await?;
- Ok(())
-}
-
#[tokio::test]
async fn read_and_write_data() {
let server = TestServer::new().unwrap();
@@ -460,6 +420,46 @@ async fn read_and_write_data() {
.await;
}
+async fn read_data_as_sql(
+ client: &reqwest::Client,
+ path: &str,
+ org_id: &str,
+ bucket_id: &str,
+ sql_query: &str,
+) -> Vec<String> {
+ let url = format!("{}{}", API_BASE, path);
+ let lines = client
+ .get(&url)
+ .query(&[
+ ("bucket", bucket_id),
+ ("org", org_id),
+ ("sql_query", sql_query),
+ ])
+ .send()
+ .await
+ .unwrap()
+ .text()
+ .await
+ .unwrap()
+ .trim()
+ .split('\n')
+ .map(str::to_string)
+ .collect();
+ lines
+}
+
+async fn write_data(
+ client: &influxdb2_client::Client,
+ org_id: &str,
+ bucket_id: &str,
+ points: Vec<influxdb2_client::DataPoint>,
+) -> Result<()> {
+ client
+ .write(org_id, bucket_id, stream::iter(points))
+ .await?;
+ Ok(())
+}
+
// Don't make a separate #test function so that we can reuse the same
// server process
async fn test_http_error_messages(client: &influxdb2_client::Client) -> Result<()> {
