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

Function TestBuildSafeOutputsSection

pkg/cli/commands_new_test.go:50–71  ·  view source on GitHub ↗

TestBuildSafeOutputsSection validates that buildSafeOutputsSection generates safe-output names that are all valid according to the JSON schema.

(t *testing.T)

Source from the content-addressed store, hash-verified

48// TestBuildSafeOutputsSection validates that buildSafeOutputsSection generates
49// safe-output names that are all valid according to the JSON schema.
50func TestBuildSafeOutputsSection(t *testing.T) {
51 section := buildSafeOutputsSection()
52
53 require.NotEmpty(t, section, "buildSafeOutputsSection should return non-empty content")
54 assert.Contains(t, section, "safe-outputs:", "Section should contain safe-outputs key")
55 assert.Contains(t, section, "create-issue:", "Section should include create-issue as active example")
56
57 // Get valid schema keys to check against
58 validKeys, err := parser.GetSafeOutputTypeKeys()
59 require.NoError(t, err, "GetSafeOutputTypeKeys should not return error")
60 require.NotEmpty(t, validKeys, "Schema should have safe output type keys")
61
62 validKeySet := make(map[string]bool, len(validKeys))
63 for _, k := range validKeys {
64 validKeySet[k] = true
65 }
66
67 for _, key := range extractSafeOutputKeys(section) {
68 assert.True(t, validKeySet[key],
69 "safe-output name %q used in 'new' template is not a valid schema key", key)
70 }
71}
72
73// TestCreateWorkflowTemplateContainsOnlyValidSafeOutputs validates that the workflow
74// template generated by the 'new' command only references safe-output names that are

Callers

nothing calls this directly

Calls 3

GetSafeOutputTypeKeysFunction · 0.92
buildSafeOutputsSectionFunction · 0.85
extractSafeOutputKeysFunction · 0.85

Tested by

no test coverage detected