Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/goose/src/providers/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ impl RequestLog {
Payload: Serialize,
{
let logs_dir = Paths::in_state_dir("logs");
fs_err::create_dir_all(&logs_dir)?;

let request_id = Uuid::new_v4();
let temp_name = format!("llm_request.{request_id}.jsonl");
Expand Down Expand Up @@ -525,6 +526,27 @@ mod tests {
use super::*;
use serde_json::json;

#[test]
fn test_request_log_start_creates_logs_dir() {
let _guard = env_lock::lock_env([("GOOSE_PATH_ROOT", None::<&str>)]);
let temp_dir = tempfile::tempdir().unwrap();
std::env::set_var("GOOSE_PATH_ROOT", temp_dir.path());

let logs_dir = Paths::in_state_dir("logs");
assert!(!logs_dir.exists(), "logs dir should not exist yet");

let log = RequestLog::start(
&ModelConfig::new("test").unwrap(),
&json!({"model": "test"}),
)
.expect("RequestLog::start should create missing logs dir");
drop(log);

assert!(logs_dir.is_dir(), "logs dir should have been created");

std::env::remove_var("GOOSE_PATH_ROOT");
}

#[test]
fn test_detect_image_path() {
// Create a temporary PNG file with valid PNG magic numbers
Expand Down
Loading