use runar_cli::{InitCommand, NodeConfig, StartCommand};
use runar_common::logging::{Component, Logger};
use std::sync::Arc;
use tempfile::TempDir;
#[tokio::test]
async fn test_config_creation() {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let config_dir = temp_dir.path().to_path_buf();
let config = NodeConfig::new(
"test_node".to_string(),
"test_network".to_string(),
"test_public_key".to_string(),
runar_cli::config::SetupServerConfig::default(),
);
config.save(&config_dir).expect("Failed to save config");
let loaded_config = NodeConfig::load(&config_dir).expect("Failed to load config");
assert_eq!(config.node_id, loaded_config.node_id);
assert_eq!(config.default_network_id, loaded_config.default_network_id);
assert_eq!(config.node_public_key, loaded_config.node_public_key);
}
#[tokio::test]
async fn test_init_command_creation() {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let config_dir = temp_dir.path().to_path_buf();
let logger = Arc::new(Logger::new_root(Component::CLI, "test"));
let _init_cmd = InitCommand::new(config_dir, logger);
}
#[tokio::test]
async fn test_start_command_creation() {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let config_dir = temp_dir.path().to_path_buf();
let logger = Arc::new(Logger::new_root(Component::CLI, "test"));
let _start_cmd = StartCommand::new(config_dir, logger);
}
#[test]
fn test_config_exists_check() {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let config_dir = temp_dir.path().to_path_buf();
assert!(!NodeConfig::exists(&config_dir));
let config = NodeConfig::new(
"test_node".to_string(),
"test_network".to_string(),
"test_public_key".to_string(),
runar_cli::config::SetupServerConfig::default(),
);
config.save(&config_dir).expect("Failed to save config");
assert!(NodeConfig::exists(&config_dir));
}