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
2 changes: 1 addition & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ chat_openai_mocked <- function(system_prompt = NULL,
model = model,
params = params,
extra_args = api_args,
api_key = api_key,
credentials = function() api_key,
provider_class = ellmer:::ProviderOpenAI
)
}
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-set_llm.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,23 @@ test_that("setting arguments for selected provider ", {
my_project <- my_project |>
set_llm(provider = "openai", model = "model_mocked")
expect_equal(
my_project$llm$.__enclos_env__$private$provider@model,
my_project$llm$get_provider()@model,
"model_mocked"
)

# Provider-related, non-default argument (not included within `llm_default_args`) is properly set
my_project <- my_project |>
set_llm(provider = "openai", api_key = "api_key_mocked")
expect_equal(
my_project$llm$.__enclos_env__$private$provider@api_key,
my_project$llm$get_provider()@credentials(),
"api_key_mocked"
)

# Chat-related, non-default argument (not included within `llm_default_args`) is properly set
my_project <- my_project |>
set_llm(provider = "openai", echo = "all")
expect_equal(
# Please don't reach into the private namespace of external R6 classes
Copy link
Member

Choose a reason for hiding this comment

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

I understand there is now no public way to check echo parameter - in that case you suggest other way to test setting echo to all?

Copy link
Author

@gadenbuie gadenbuie Nov 17, 2025

Choose a reason for hiding this comment

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

Personally, I wouldn't recommend testing this. If you're only passing echo from set_llm() to chat_*(), I think there's very little utility in having a test, unless some part of your package explicitly depends on the values of echo used by ellmer.

My view is that tests in your package shouldn't cover behavior from another package. What would happen if ellmer changed the allowed values of echo? If some part of your package would break as a result, you should write a test around that potential breakage. But if users of your package would be able to pass those new values through echo, then you don't need a test.

The fact that this test just covers "was echo set?" seems to me to be a sign that the test isn't necessary.

Copy link
Member

Choose a reason for hiding this comment

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

You're absolutely right @gadenbuie .

my_project$llm$.__enclos_env__$private$echo,
"all"
)
Expand Down