Skip to content

Add focused PNG round-trip SDK tests#10

Merged
harshaneel merged 1 commit into
mainfrom
hg/png-roundtrip-test
Jun 1, 2026
Merged

Add focused PNG round-trip SDK tests#10
harshaneel merged 1 commit into
mainfrom
hg/png-roundtrip-test

Conversation

@harshaneel
Copy link
Copy Markdown
Owner

Summary

PNG image support was already in the proxy, but only covered transitively by TestSDKGenAIGenerateContent where a PNG part is one item among many. This PR adds four dedicated tests that prove PNG bytes survive every supported entry point intact.

Test Entry point Expected upstream shape
TestSDKGenAIPNGInlineData genai inlineData with image/png data:image/png;base64,<base64> image_url part
TestSDKGenAIPNGFileDataDataURI genai fileData with data: URI URI preserved verbatim
TestSDKGenAIPNGFileDataHTTPURL genai fileData with https:// URL URL passed through unmodified
TestSDKOpenAIPNGImagePassthrough openai-go chat completions with image content part byte-for-byte passthrough

A shared assertUpstreamHasImageURL helper walks the structured upstream body for the three genai cases. The OpenAI passthrough test uses strings.Contains since the proxy never decodes the body on that route.

Test plan

  • make lint clean
  • make test-unit green
  • go test ./integration green: all four new tests pass
  • Both code-reviewer agents run; only LOW findings, addressed where worthwhile (added clarifying comment on the OpenAI test's different assertion strategy; skipped t.Parallel() to match the existing convention in sdk_test.go)

PR B (Tesseract-backed OCR for PNG) coming next.

🤖 Generated with Claude Code

Confirms PNG bytes survive translation through the proxy intact for
every supported entry point:

- genai inlineData with image/png becomes a data:image/png;base64,...
  image_url part upstream
- genai fileData with a data: URI is preserved verbatim
- genai fileData with an https URL passes through unmodified (no
  re-encoding)
- openai-go chat completions with an image content part flows through
  the raw passthrough byte-for-byte

A shared assertUpstreamHasImageURL helper walks the structured upstream
body for the three genai cases; the OpenAI passthrough test uses
strings.Contains since the proxy never decodes the body on that route.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@harshaneel harshaneel merged commit 4538828 into main Jun 1, 2026
5 of 6 checks passed
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