MCPcopy Create free account
hub / github.com/github/gh-aw / TestGenerateDispatchRepositoryTool

Function TestGenerateDispatchRepositoryTool

pkg/workflow/dispatch_repository_test.go:468–508  ·  view source on GitHub ↗

TestGenerateDispatchRepositoryTool tests that tool definitions are generated correctly

(t *testing.T)

Source from the content-addressed store, hash-verified

466
467// TestGenerateDispatchRepositoryTool tests that tool definitions are generated correctly
468func TestGenerateDispatchRepositoryTool(t *testing.T) {
469 toolConfig := &DispatchRepositoryToolConfig{
470 Description: "Trigger CI in another repository",
471 Workflow: "ci.yml",
472 EventType: "ci_trigger",
473 Repository: "org/target-repo",
474 Inputs: map[string]any{
475 "environment": map[string]any{
476 "type": "choice",
477 "description": "Target environment",
478 "options": []any{"staging", "production"},
479 "default": "staging",
480 },
481 "message": map[string]any{
482 "type": "string",
483 "description": "Optional message",
484 },
485 },
486 }
487
488 tool := generateDispatchRepositoryTool("trigger_ci", toolConfig)
489
490 assert.Equal(t, "trigger_ci", tool["name"], "Tool name should match key")
491 assert.NotEmpty(t, tool["description"], "Tool should have a description")
492 assert.Equal(t, "trigger_ci", tool["_dispatch_repository_tool"], "Should have routing metadata")
493
494 inputSchema, ok := tool["inputSchema"].(map[string]any)
495 require.True(t, ok, "Tool should have inputSchema")
496
497 properties, ok := inputSchema["properties"].(map[string]any)
498 require.True(t, ok, "inputSchema should have properties")
499
500 assert.Contains(t, properties, "environment", "Should have environment property")
501 assert.Contains(t, properties, "message", "Should have message property")
502
503 envProp, ok := properties["environment"].(map[string]any)
504 require.True(t, ok, "environment property should be a map")
505 assert.Equal(t, "string", envProp["type"])
506 assert.Contains(t, envProp, "enum", "choice type should have enum")
507 assert.Equal(t, "staging", envProp["default"])
508}
509
510// TestGenerateDispatchRepositoryTool_NameNormalization tests underscore normalization
511func TestGenerateDispatchRepositoryTool_NameNormalization(t *testing.T) {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected