Skip to content

Add unit tests and testdata for azure.ai.agents extension#7634

Merged
glharper merged 3 commits intotrangevi/toolboxfrom
glharper/ai-agents-test-coverage
Apr 10, 2026
Merged

Add unit tests and testdata for azure.ai.agents extension#7634
glharper merged 3 commits intotrangevi/toolboxfrom
glharper/ai-agents-test-coverage

Conversation

@glharper
Copy link
Copy Markdown
Member

Summary

Adds 86 new unit tests and 7 testdata fixtures for the azure.ai.agents extension, raising the total test count from 183 to 269. All new tests are pure-function unit tests that require no external dependencies.

Coverage Improvements

Package Before After Change
agent_yaml 23.1% 53.8% +30.7%
registry_api 0% 28.8% +28.8%
agent_api 0% tested new
cmd 23.0% 23.6% +0.6%

New Test Files

Phase 1: Pure Function Tests

  • agent_yaml/map_test.go (44 tests) - YAML-to-API mapping functions
  • registry_api/helpers_test.go (35 tests) - Tool conversion, parameter conversion, manifest merge, placeholder injection
  • agent_api/models_test.go (24 tests) - JSON round-trip serialization for all model types
  • cmd/init_copy_test.go - copyDirectory, copyFile logic tests
  • cmd/agent_context_test.go - buildAgentEndpoint construction test

Phase 4: Testdata Fixtures

  • 7 YAML fixtures in agent_yaml/testdata/: 3 valid agents, 1 MCP tools agent, 3 invalid manifests
  • agent_yaml/testdata_test.go (14 subtests) - Fixture-based parsing + regression tests against tests/samples/

Test Conventions Followed

  • Table-driven subtests with t.Run and t.Parallel()
  • stdlib testing in packages that don't use testify; testify/assert+require where already established
  • Go 1.26 patterns (new(val), t.Context(), t.TempDir())
  • Microsoft copyright headers on all files

Add 86 new unit tests across 5 previously untested or undertested packages
in the azure.ai.agents extension, raising total test count from 183 to 269.

Coverage improvements:
- agent_yaml: 23.1% -> 53.8% (map.go YAML-to-API mapping fully tested)
- registry_api: 0% -> 28.8% (tool conversion, parameter conversion, merge)
- agent_api: 0% -> tested (JSON round-trip for all model types)
- cmd: 23.0% -> 23.6% (copyDirectory, copyFile, buildAgentEndpoint)

New test files:
- agent_yaml/map_test.go: 44 tests for YAML-to-API transform functions
- registry_api/helpers_test.go: 35 tests for pure conversion helpers
- agent_api/models_test.go: 24 JSON serialization round-trip tests
- cmd/init_copy_test.go: directory/file copy logic tests
- cmd/agent_context_test.go: endpoint construction test
- agent_yaml/testdata_test.go: fixture-based parsing + regression tests

New testdata fixtures (7 YAML files):
- 3 valid agents (minimal prompt, full prompt, hosted)
- 1 MCP tools agent
- 3 invalid manifests (no kind, no model, empty template)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

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

Solid test additions - good edge case coverage and clean table-driven pattern throughout. One convention note inline.

glharper and others added 2 commits April 10, 2026 12:04
Replace the generic ptr[T](v T) *T helper function with Go 1.26's
built-in new(val) pattern in models_test.go and helpers_test.go,
consistent with map_test.go and AGENTS.md conventions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@glharper glharper merged commit af85a8f into trangevi/toolbox Apr 10, 2026
14 checks passed
trangevi added a commit that referenced this pull request Apr 10, 2026
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.

2 participants