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

Function TestValidateToolConfiguration

pkg/workflow/compiler_validators_test.go:358–426  ·  view source on GitHub ↗

TestValidateToolConfiguration tests safe-outputs, GitHub tools, and dispatch validation.

(t *testing.T)

Source from the content-addressed store, hash-verified

356
357// TestValidateToolConfiguration tests safe-outputs, GitHub tools, and dispatch validation.
358func TestValidateToolConfiguration(t *testing.T) {
359 tests := []struct {
360 name string
361 workflowData *WorkflowData
362 permissions string // raw permissions YAML to parse
363 shouldError bool
364 errorContains string
365 }{
366 {
367 name: "minimal workflow passes",
368 workflowData: &WorkflowData{
369 Name: "Test",
370 MarkdownContent: "# Test",
371 AI: "copilot",
372 },
373 permissions: "",
374 shouldError: false,
375 },
376 {
377 name: "agentic-workflows tool requires actions read permission",
378 workflowData: &WorkflowData{
379 Name: "Test",
380 MarkdownContent: "# Test",
381 AI: "copilot",
382 Tools: map[string]any{
383 "agentic-workflows": map[string]any{},
384 },
385 Permissions: "",
386 },
387 permissions: "",
388 shouldError: true,
389 errorContains: "Missing required permission for agentic-workflows tool",
390 },
391 {
392 name: "agentic-workflows tool with actions read succeeds",
393 workflowData: &WorkflowData{
394 Name: "Test",
395 MarkdownContent: "# Test",
396 AI: "copilot",
397 Tools: map[string]any{
398 "agentic-workflows": map[string]any{},
399 },
400 Permissions: "permissions:\n actions: read\n",
401 },
402 permissions: "permissions:\n actions: read\n",
403 shouldError: false,
404 },
405 }
406
407 for _, tt := range tests {
408 t.Run(tt.name, func(t *testing.T) {
409 tmpDir := testutil.TempDir(t, "tool-test")
410 markdownPath := filepath.Join(tmpDir, "test.md")
411
412 compiler := NewCompiler()
413 parsedPermissions := NewPermissionsParser(tt.permissions).ToPermissions()
414
415 err := compiler.validateToolConfiguration(tt.workflowData, markdownPath, parsedPermissions)

Callers

nothing calls this directly

Calls 7

TempDirFunction · 0.92
NewCompilerFunction · 0.85
NewPermissionsParserFunction · 0.85
ToPermissionsMethod · 0.80
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected