Skip to content
Merged
Show file tree
Hide file tree
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
35 changes: 22 additions & 13 deletions crates/goose/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,28 @@ mod tests {

#[test]
fn test_model_config_context_limits() {
let config = ModelConfig::new("claude-3-opus")
.unwrap()
.with_context_limit(Some(150_000));
assert_eq!(config.context_limit(), 150_000);

let config = ModelConfig::new("claude-3-opus").unwrap();
assert_eq!(config.context_limit(), 200_000);

let config = ModelConfig::new("gpt-4-turbo").unwrap();
assert_eq!(config.context_limit(), 128_000);

let config = ModelConfig::new("unknown-model").unwrap();
assert_eq!(config.context_limit(), DEFAULT_CONTEXT_LIMIT);
// Clear all GOOSE environment variables to ensure clean test environment
with_var("GOOSE_TEMPERATURE", None::<&str>, || {
Copy link
Collaborator

@DOsinga DOsinga Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this with_var looks nice, but shouldn't this be at the other test that actually sets these? of course relying on these in tests is crazy to begin with

ceterum censeo variabiles ambientis esse delendas

with_var("GOOSE_CONTEXT_LIMIT", None::<&str>, || {
with_var("GOOSE_TOOLSHIM", None::<&str>, || {
with_var("GOOSE_TOOLSHIM_OLLAMA_MODEL", None::<&str>, || {
let config = ModelConfig::new("claude-3-opus")
.unwrap()
.with_context_limit(Some(150_000));
assert_eq!(config.context_limit(), 150_000);

let config = ModelConfig::new("claude-3-opus").unwrap();
assert_eq!(config.context_limit(), 200_000);

let config = ModelConfig::new("gpt-4-turbo").unwrap();
assert_eq!(config.context_limit(), 128_000);

let config = ModelConfig::new("unknown-model").unwrap();
assert_eq!(config.context_limit(), DEFAULT_CONTEXT_LIMIT);
});
});
});
});
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/goose/src/providers/claude_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ impl Provider for ClaudeCodeProvider {
mod tests {
use super::ModelConfig;
use super::*;
use temp_env::with_var;

#[test]
fn test_claude_code_model_config() {
Expand Down
Loading