fix(r): support ellmer 0.5.0's Provider/Model API in test mocks - #284
Merged
Conversation
ellmer 0.5.0 moves model details from Provider into a new Model class: Provider() no longer accepts model as its second positional argument, and Chat$new() requires a separate model argument. Gate the mock chat client construction on whether ellmer::Model exists so tests pass on both old and new ellmer. Fixes #283
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #283.
ellmer 0.5.0 moves model details from
Providerinto a newModelclass:Provider()no longer takesmodelas its second positional argument, andChat$new()now requires a separatemodelargument. This broke two test fixtures that constructedMockChat$new(ellmer::Provider("test", "test", "test")):tests/testthat/helper-fixtures.R—mock_ellmer_chat_client()tests/testthat/apps/basic/app.RThis PR adds a version-agnostic construction that branches on whether
ellmer::Modelexists, so the mocks work on both old (≤ 0.4.2) and new (≥ 0.5.0) ellmer:MockChat$new(ellmer::Provider("test", "test"), model = ellmer::Model(name = "test"))MockChat$new(ellmer::Provider("test", "test", "test"))Both previously-failing test files (
test-QueryChat.R,test-querychat_module.R) now pass with dev ellmer installed locally. The 4TblSqlSourcefailures seen in a fulldevtools::test()run are pre-existing (a duckdb/dbplyr CTE-naming issue) and fail identically onmain, so they're out of scope here.