-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3687dfc
commit 761e597
Showing
4 changed files
with
39 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
mod duckdb_load; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Hardcoded file path for demonstration | ||
// In a real application, you might want to make this configurable | ||
let file_path = "test_files/hotosm_twn_populated_places_points_geojson.geojson"; | ||
|
||
println!("Processing file: {}", file_path); | ||
|
||
// Call the process_file function from the duckload module | ||
match duckdb_load::process_file(file_path) { | ||
Ok(_) => println!("File processed successfully."), | ||
Err(e) => eprintln!("Error processing file: {}", e), | ||
Ok(_) => { | ||
println!("File processed successfully."); | ||
Ok(()) | ||
} | ||
Err(e) => { | ||
eprintln!("Error processing file: {}", e); | ||
Err(Box::new(e)) | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
invalid file for testing | ||
test file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,25 @@ | ||
use duckdb_transformer::duckdb_load::process_file; | ||
use std::path::Path; | ||
|
||
const TEST_FILES_DIR: &str = "test_files"; | ||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use std::path::Path; | ||
|
||
fn test_file_path(file_name: &str) -> String { | ||
Path::new(TEST_FILES_DIR) | ||
.join(file_name) | ||
.to_str() | ||
.unwrap() | ||
.to_string() | ||
} | ||
#[test] | ||
fn test_process_geojson_file() { | ||
let file_path = "test_files/hotosm_twn_populated_places_points_geojson.geojson"; | ||
|
||
#[test] | ||
fn test_process_invalid_file() { | ||
let file_path = test_file_path("invalid.txt"); | ||
assert!(process_file(&file_path).is_err()); | ||
} | ||
// Ensure the file exists | ||
assert!(Path::new(file_path).exists(), "Test file does not exist"); | ||
|
||
#[test] | ||
fn test_process_geojson() { | ||
let file_path = test_file_path("hotosm_twn_populated_places_points_geojson.geojson"); | ||
assert!(process_file(&file_path).is_ok()); | ||
} | ||
// Process the file | ||
let result = process_file(file_path); | ||
|
||
#[test] | ||
fn test_process_geopackage() { | ||
let file_path = test_file_path("GLA_High_Street_boundaries.gpkg"); | ||
assert!(process_file(&file_path).is_ok()); | ||
// Check if the processing was successful | ||
assert!( | ||
result.is_ok(), | ||
"Failed to process the file: {:?}", | ||
result.err() | ||
); | ||
} | ||
} | ||
|
||
// #[test] | ||
// fn test_process_shapefile() { | ||
// let file_path = test_file_path("your_shapefile.shp"); | ||
// assert!(process_file(&file_path).is_ok()); | ||
// } | ||
|
||
// #[test] | ||
// fn test_process_excel() { | ||
// let file_path = test_file_path("your_excel_file.xlsx"); | ||
// assert!(process_file(&file_path).is_ok()); | ||
// } | ||
|
||
// #[test] | ||
// fn test_process_csv() { | ||
// let file_path = test_file_path("your_csv_file.csv"); | ||
// assert!(process_file(&file_path).is_ok()); | ||
// } | ||
|
||
// #[test] | ||
// fn test_process_parquet() { | ||
// let file_path = test_file_path("your_parquet_file.parquet"); | ||
// assert!(process_file(&file_path).is_ok()); | ||
// } |