use datafold::datafold_node::config::NodeConfig;
use datafold::datafold_node::DataFoldNode;
use tempfile::TempDir;
#[tokio::test(flavor = "multi_thread")]
async fn test_node_starts_without_schema_service() {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let test_db_path = temp_dir.path().join("test_db");
let config = NodeConfig::new(test_db_path.to_path_buf())
.with_network_listen_address("/ip4/127.0.0.1/tcp/9002");
let result = DataFoldNode::new(config).await;
assert!(
result.is_ok(),
"Node creation should succeed when schema_service_url is None"
);
println!("✅ Node correctly starts when schema service is not configured!");
}
#[tokio::test(flavor = "multi_thread")]
async fn test_node_new_loads_schemas_for_testing() {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let test_db_path = temp_dir.path().join("test_db");
let config = NodeConfig::new(test_db_path.to_path_buf())
.with_network_listen_address("/ip4/127.0.0.1/tcp/9003")
.with_schema_service_url("test://mock");
let node = DataFoldNode::new(config)
.await
.expect("Failed to create DataFoldNode with mock schema service");
let fold_db = node.get_fold_db().await.expect("Failed to get FoldDB");
let schema_manager = fold_db.schema_manager();
let schemas = schema_manager.get_schemas().expect("Failed to get schemas");
assert_eq!(
schemas.len(),
0,
"No schemas should be auto-loaded with mock schema service"
);
println!("✅ DataFoldNode correctly starts with mock schema service for testing!");
}