10000 Add PromptTest by jameslong · Pull Request #14 · jameslong/vancouver · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add PromptTest #14

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

Merged
merged 2 commits into from
Jun 17, 2025
Merged

Add PromptTest #14

merged 2 commits into from
Jun 17, 2025

Conversation

jameslong
Copy link
Owner

This pull request introduces a new module, Vancouver.PromptTest, to provide utility functions for testing prompts, along with a comprehensive test suite in Vancouver.Test.PromptTest to validate these utilities. The changes aim to streamline the testing of responses for different content types (audio, image, text) and ensure robust handling of various scenarios.

New Testing Utilities:

  • Added Vancouver.PromptTest module with functions to process and validate responses (audio_response/1, image_response/1, text_response/1), build request bodies (build_request/2), and extract roles (get_role/1). These utilities simplify testing by encapsulating common logic.

Test Suite for Utilities:

  • Introduced Vancouver.Test.PromptTest with unit tests for each utility function:
    • Validated correct behavior for audio_response/1, image_response/1, and text_response/1 with valid and invalid inputs.
    • Tested build_request/2 to ensure it generates properly formatted request payloads.

@jameslong jameslong self-assigned this Jun 17, 2025
@jameslong jameslong requested a review from Copilot June 17, 2025 15:16
Copy link
Contributor
@Copilot Copilot AI left a 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 adds a Vancouver.PromptTest helper module for testing JSON-RPC prompt responses (audio, image, text) and a corresponding Vancouver.Test.PromptTest suite to verify its behavior.

  • Introduce Vancouver.PromptTest with functions: audio_response/1, image_response/1, text_response/1, build_request/2, and get_role/1.
  • Add Vancouver.Test.PromptTest tests covering valid and invalid scenarios for each utility.
  • Provide build_success_conn/2 helper in tests to simulate successful JSON-RPC responses.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/vancouver/test/prompt_test.ex Implemented test utilities for parsing and validating responses
test/vancouver/test/prompt_test.exs Added unit tests for each utility and a helper to build test conns
Comments suppressed due to low confidence (5)

test/vancouver/test/prompt_test.exs:10

  • The describe block references build_request/3 but the function signature is build_request/2. Please update the description to /2.
  describe "build_request/3" do

lib/vancouver/test/prompt_test.ex:16

  • The spec indicates an atom-keyed map, but the function returns a string-keyed map (e.g., %{"data" => ..., "mimeType" => ...}). Update the spec to reflect a map() or the correct key types.
  @spec audio_response(Plug.Conn.t()) :: %{data: String.t(), mimeType: String.t()}

lib/vancouver/test/prompt_test.ex:18

  • The JSON module isn't aliased or imported; this will cause a compile error. Consider aliasing your JSON library (e.g., alias Jason) or replacing JSON.decode! with the proper module (e.g., Jason.decode!).
    response = JSON.decode!(conn.resp_body)

test/vancouver/test/prompt_test.exs:158

  • The JSON module isn't available in the test; you need to alias your JSON encoder (e.g., alias Jason) or call the correct module (e.g., Jason.encode!).
    |> Map.put(:resp_body, JSON.encode!(body))

lib/vancouver/test/prompt_test.ex:33

  • The module path (lib/vancouver/test/prompt_test.ex) doesn’t align with the module namespace Vancouver.PromptTest. Consider moving the file to lib/vancouver/prompt_test.ex to match Elixir conventions.
  @spec build_request(String.t(), map()) :: map()

@jameslong jameslong merged commit f87e90a into main Jun 17, 2025
1 check passed
@jameslong jameslong deleted the prompt_test branch June 17, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0