-
Notifications
You must be signed in to change notification settings - Fork 1
Testing tools #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Used to test all response helpers.
This allows for simpler, concurrent testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces testing utilities for tool modules, updates JSON response formatting in the core Vancouver.Tool
, and modifies the router/dispatch pipeline to pass tool lists via assigns.
- Add ExUnit tests for
TestResponse
andCalculateSum
tools and shared test helpers inToolTest
- Change all
send_*
functions inVancouver.Tool
to emit string keys for JSON compatibility - Update router to use
copy_opts_to_assign
and read tool list fromconn.assigns
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/vancouver/tools/test_response_test.exs | Add tests for Vancouver.Tools.TestResponse responses |
test/vancouver/tools/calculate_sum_test.exs | Add basic test for Vancouver.Tools.CalculateSum running sum logic |
test/vancouver/test/tool_test.exs | Add shared helper functions and assertions for tool call and outputs |
lib/vancouver/tools/test_response.ex | Implement TestResponse tool with various response types |
lib/vancouver/tool.ex | Change JSON payload keys from atoms to strings in all send_* funcs |
lib/vancouver/router.ex | Use copy_opts_to_assign for passing router opts and compact DSL |
lib/vancouver/plugs/pipeline.ex | Minor formatting tweak in pipeline builder |
lib/vancouver/plugs/dispatch.ex | Read tool list from conn.assigns instead of application env |
README.md | Update config and routing example to pass tools via forward |
Comments suppressed due to low confidence (2)
test/vancouver/test/tool_test.exs:1
- [nitpick] The test module is named
Vancouver.Test.ToolTest
but the implementation module isVancouver.ToolTest
; consider renaming the test module (and its path) toVancouver.ToolTest
for consistency.
defmodule Vancouver.Test.ToolTest do
test/vancouver/tools/test_response_test.exs:48
- The test uses
JSON.encode!
but there's no alias or import forJSON
; addalias JSON
or use the proper JSON module (e.g.,Jason
) to avoid undefined module errors.
|> conn("/", JSON.encode!(body))
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces several enhancements and refactors to the Vancouver library, focusing on improving tool configuration, response handling, and test coverage. Key changes include dynamic tool assignment, updates to response structures, and the addition of comprehensive test modules for tools and their responses.
Tool Configuration and Routing Updates:
config.ex
androuter.ex
to allow dynamic tool assignment via thetools
option, enabling more flexible routing configurations (README.md
,lib/vancouver/router.ex
). [1] [2]Vancouver.Plugs.Dispatch
to retrieve tools fromconn.assigns
instead of application environment, improving request-specific tool handling (lib/vancouver/plugs/dispatch.ex
).Response Structure Refactors:
Vancouver.Tool
to use string keys instead of atom keys for JSON compatibility (lib/vancouver/tool.ex
). [1] [2] [3] [4]New Tool and Testing Utilities:
Vancouver.Tools.TestResponse
, a tool for testing various response types such as audio, text, image, and error responses (lib/vancouver/tools/test_response.ex
).Vancouver.ToolTest
, a utility module providing helper functions for testing tool responses (lib/vancouver/test/tool_test.ex
).Test Suite Enhancements:
TestResponse
andCalculateSum
tools, ensuring correctness of tool responses under various scenarios (test/vancouver/tools/test_response_test.exs
,test/vancouver/tools/calculate_sum_test.exs
). [1] [2]Vancouver.ToolTest
utilities to validate their behavior and error handling (test/vancouver/test/tool_test.exs
).These changes collectively improve the flexibility, reliability, and testability of the Vancouver library.