#![cfg(feature = "httpfs-extension")]
use akar_main::{Connection, Database, SystemConfig};
use std::sync::Arc;
use tempfile::tempdir;
#[test]
fn test_httpfs_extension() -> Result<(), String> {
let dir = tempdir().map_err(|e| e.to_string())?;
let db = Arc::new(Database::new(dir.path().to_str().unwrap(), SystemConfig::default()).map_err(|e| e.to_string())?);
let conn = Connection::new(&db);
let res = conn.query("RETURN http_get('https://example.com/') AS body")?;
let chunk = res.chunks.first().unwrap();
let body = match chunk.get_value(0, 0).unwrap() {
akar_common::types::Value::String(s) => s,
_ => panic!("Expected string"),
};
assert!(
body.contains("Example Domain"),
"http_get should fetch the URL successfully"
);
let res2 = conn.query("CALL http_scan('https://example.com/')").unwrap();
println!("RES2: {:?}", res2);
let path = res2.message.expect("http_scan should return a message with the path");
assert!(!path.is_empty(), "http_scan should return a temp file path");
Ok(())
}