ralph-coder 0.2.1

An agentic code generation CLI powered by multiple LLM backends
Documentation
/// Session log tests — verifies events are written to ~/.ralph/logs/.
/// We can't easily control the log path (it uses home dir), so we test
/// that log_event doesn't panic and that calling it multiple times
/// appends to the same file.
use ralph::config::{Config, SessionConfig};
use ralph::session::Session;
use tempfile::TempDir;

fn test_config(sessions_dir: &str) -> Config {
    let mut config = Config::default();
    config.session = SessionConfig {
        auto_resume: false,
        sessions_dir: Some(sessions_dir.to_string()),
        clean_after_days: 30,
    };
    config
}

#[test]
fn log_event_does_not_panic() {
    let dir = TempDir::new().unwrap();
    let workspace = dir.path().join("ws");
    std::fs::create_dir_all(&workspace).unwrap();
    let sessions_dir = dir.path().join("sessions");
    let config = test_config(&sessions_dir.display().to_string());

    let session = Session::create(&workspace, "anthropic", "claude-sonnet-4-6", &config).unwrap();

    // Should not panic regardless of whether ~/.ralph/logs/ exists
    session.log_event("test event 1");
    session.log_event("test event 2");
    session.log_event("test event 3");
}