2026-01-23 16:13:23 +00:00
|
|
|
//! Integration tests for Nickel configuration loading
|
|
|
|
|
|
2026-02-03 22:29:15 +00:00
|
|
|
use std::path::PathBuf;
|
2026-01-23 16:13:23 +00:00
|
|
|
|
|
|
|
|
use kogral_core::config::nickel;
|
|
|
|
|
use kogral_core::config::schema::{EmbeddingProvider, KbConfig, StorageType};
|
|
|
|
|
|
|
|
|
|
fn workspace_dir() -> PathBuf {
|
|
|
|
|
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
|
|
|
path.pop(); // kb-core
|
|
|
|
|
path.pop(); // crates
|
|
|
|
|
path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
#[ignore] // Requires Nickel CLI to be installed
|
|
|
|
|
fn test_load_minimal_config() {
|
|
|
|
|
if !nickel::is_nickel_available() {
|
|
|
|
|
eprintln!("Skipping: Nickel CLI not available");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let config_path = workspace_dir().join("config/minimal.ncl");
|
|
|
|
|
let config: KbConfig = nickel::load_nickel_config(&config_path).expect("Failed to load config");
|
|
|
|
|
|
|
|
|
|
assert_eq!(config.graph.name, "minimal-kb");
|
|
|
|
|
assert_eq!(config.graph.version, "1.0.0");
|
|
|
|
|
assert_eq!(config.storage.primary, StorageType::Filesystem);
|
|
|
|
|
assert_eq!(config.embeddings.provider, EmbeddingProvider::Fastembed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
#[ignore] // Requires Nickel CLI to be installed
|
|
|
|
|
fn test_load_defaults_config() {
|
|
|
|
|
if !nickel::is_nickel_available() {
|
|
|
|
|
eprintln!("Skipping: Nickel CLI not available");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let config_path = workspace_dir().join("config/defaults.ncl");
|
|
|
|
|
let config: KbConfig = nickel::load_nickel_config(&config_path).expect("Failed to load config");
|
|
|
|
|
|
|
|
|
|
assert_eq!(config.graph.name, "my-project-kb");
|
|
|
|
|
assert_eq!(config.graph.description, "Project KOGRAL");
|
|
|
|
|
assert_eq!(config.embeddings.dimensions, 384);
|
|
|
|
|
assert_eq!(config.query.max_results, 10);
|
|
|
|
|
assert_eq!(config.query.similarity_threshold, 0.4);
|
|
|
|
|
assert!(config.mcp.tools.search);
|
|
|
|
|
assert!(config.sync.auto_index);
|
|
|
|
|
assert_eq!(config.sync.debounce_ms, 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
#[ignore] // Requires Nickel CLI to be installed
|
|
|
|
|
fn test_load_production_config() {
|
|
|
|
|
if !nickel::is_nickel_available() {
|
|
|
|
|
eprintln!("Skipping: Nickel CLI not available");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let config_path = workspace_dir().join("config/production.ncl");
|
|
|
|
|
let config: KbConfig = nickel::load_nickel_config(&config_path).expect("Failed to load config");
|
|
|
|
|
|
|
|
|
|
assert_eq!(config.graph.name, "tools-ecosystem-kb");
|
|
|
|
|
assert!(config.storage.secondary.enabled);
|
|
|
|
|
assert_eq!(config.storage.secondary.namespace, "tools_kb");
|
|
|
|
|
assert_eq!(config.storage.secondary.database, "production");
|
|
|
|
|
assert_eq!(config.embeddings.provider, EmbeddingProvider::Openai);
|
|
|
|
|
assert_eq!(config.embeddings.model, "text-embedding-3-small");
|
|
|
|
|
assert_eq!(config.query.similarity_threshold, 0.5);
|
|
|
|
|
assert!(!config.query.cross_graph);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_nickel_availability() {
|
|
|
|
|
let available = nickel::is_nickel_available();
|
|
|
|
|
println!("Nickel CLI available: {}", available);
|
|
|
|
|
|
|
|
|
|
if available {
|
|
|
|
|
let version = nickel::nickel_version().expect("Failed to get version");
|
|
|
|
|
println!("Nickel version: {}", version);
|
|
|
|
|
}
|
|
|
|
|
}
|