diff --git a/quickwit/quickwit-cli/tests/cli.rs b/quickwit/quickwit-cli/tests/cli.rs
index 15c4ff3d8be..27b9ecc7a3a 100644
--- a/quickwit/quickwit-cli/tests/cli.rs
+++ b/quickwit/quickwit-cli/tests/cli.rs
@@ -22,11 +22,10 @@
mod helpers;
use std::path::Path;
-use std::str::FromStr;
use anyhow::Result;
use clap::error::ErrorKind;
-use helpers::{TestEnv, TestStorageType};
+use helpers::{uri_from_path, TestEnv, TestStorageType};
use quickwit_cli::checklist::ChecklistError;
use quickwit_cli::cli::build_cli;
use quickwit_cli::index::{
@@ -258,15 +257,17 @@ async fn test_ingest_docs_cli() {
// Ensure cache directory is empty.
let cache_directory_path = get_cache_directory_path(&test_env.data_dir_path);
- let data_dir_uri = Uri::from_str(test_env.data_dir_path.to_str().unwrap()).unwrap();
-
assert!(cache_directory_path.read_dir().unwrap().next().is_none());
+ let does_not_exit_uri = uri_from_path(&test_env.data_dir_path)
+ .join("file-does-not-exist.json")
+ .unwrap();
+
// Ingest a non-existing file should fail.
let args = LocalIngestDocsArgs {
config_uri: test_env.resource_files.config,
index_id: test_env.index_id,
- input_path_opt: Some(data_dir_uri.join("file-does-not-exist.json").unwrap()),
+ input_path_opt: Some(does_not_exit_uri),
input_format: SourceInputFormat::Json,
overwrite: false,
clear_cache: true,
diff --git a/quickwit/quickwit-cli/tests/helpers.rs b/quickwit/quickwit-cli/tests/helpers.rs
index a3e18bc847a..67839f7368b 100644
--- a/quickwit/quickwit-cli/tests/helpers.rs
+++ b/quickwit/quickwit-cli/tests/helpers.rs
@@ -18,7 +18,7 @@
// along with this program. If not, see .
use std::fs;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
@@ -191,8 +191,8 @@ pub enum TestStorageType {
LocalFileSystem,
}
-fn uri_from_path(path: PathBuf) -> Uri {
- Uri::from_str(&format!("file://{}", path.display())).unwrap()
+pub fn uri_from_path(path: &Path) -> Uri {
+ Uri::from_str(path.to_str().unwrap()).unwrap()
}
/// Creates all necessary artifacts in a test environment.
@@ -264,12 +264,12 @@ pub async fn create_test_env(
.context("failed to parse cluster endpoint")?;
let resource_files = TestResourceFiles {
- config: uri_from_path(node_config_path),
- index_config: uri_from_path(index_config_path),
- index_config_without_uri: uri_from_path(index_config_without_uri_path),
- index_config_with_retention: uri_from_path(index_config_with_retention_path),
- log_docs: uri_from_path(log_docs_path),
- wikipedia_docs: uri_from_path(wikipedia_docs_path),
+ config: uri_from_path(&node_config_path),
+ index_config: uri_from_path(&index_config_path),
+ index_config_without_uri: uri_from_path(&index_config_without_uri_path),
+ index_config_with_retention: uri_from_path(&index_config_with_retention_path),
+ log_docs: uri_from_path(&log_docs_path),
+ wikipedia_docs: uri_from_path(&wikipedia_docs_path),
};
Ok(TestEnv {
diff --git a/quickwit/quickwit-common/src/fs.rs b/quickwit/quickwit-common/src/fs.rs
index adcb432e1b1..1aaa43d8286 100644
--- a/quickwit/quickwit-common/src/fs.rs
+++ b/quickwit/quickwit-common/src/fs.rs
@@ -34,7 +34,7 @@ pub async fn empty_dir>(path: P) -> anyhow::Result<()> {
Ok(())
}
-/// Helper function to get the cache path.
+/// Helper function to get the indexer split cache path.
pub fn get_cache_directory_path(data_dir_path: &Path) -> PathBuf {
data_dir_path.join("indexer-split-cache").join("splits")
}
diff --git a/quickwit/quickwit-config/src/source_config/mod.rs b/quickwit/quickwit-config/src/source_config/mod.rs
index 04eb90ec8a1..de9258a113c 100644
--- a/quickwit/quickwit-config/src/source_config/mod.rs
+++ b/quickwit/quickwit-config/src/source_config/mod.rs
@@ -20,10 +20,8 @@
pub(crate) mod serialize;
use std::num::NonZeroUsize;
-use std::path::Path;
use std::str::FromStr;
-use anyhow::Context;
use bytes::Bytes;
use quickwit_common::is_false;
use quickwit_common::uri::Uri;
@@ -241,14 +239,6 @@ impl SourceParams {
FileSourceParams::from_str(filepath.as_ref()).map(Self::File)
}
- pub fn file_from_path>(filepath: P) -> anyhow::Result {
- let path_str = filepath
- .as_ref()
- .to_str()
- .context("failed to convert path to string")?;
- Self::file_from_str(path_str)
- }
-
pub fn stdin() -> Self {
Self::File(FileSourceParams { filepath: None })
}