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

Function TestGetRequiredSecretsForWorkflow

pkg/cli/workflow_secrets_test.go:16–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestGetRequiredSecretsForWorkflow(t *testing.T) {
17 // Create a temporary directory with test workflow files
18 tempDir := t.TempDir()
19 workflowsDir := filepath.Join(tempDir, ".github", "workflows")
20 err := os.MkdirAll(workflowsDir, 0755)
21 require.NoError(t, err, "Should create workflows directory")
22
23 tests := []struct {
24 name string
25 workflowContent string
26 expectedSecretName string
27 expectNil bool
28 }{
29 {
30 name: "copilot engine workflow",
31 workflowContent: `---
32engine: copilot
33on: push
34---
35# Copilot Workflow`,
36 expectedSecretName: "COPILOT_GITHUB_TOKEN",
37 expectNil: false,
38 },
39 {
40 name: "claude engine workflow",
41 workflowContent: `---
42engine: claude
43on: push
44---
45# Claude Workflow`,
46 expectedSecretName: "ANTHROPIC_API_KEY",
47 expectNil: false,
48 },
49 {
50 name: "workflow without engine",
51 workflowContent: `---
52on: push
53---
54# No Engine Workflow`,
55 expectedSecretName: "COPILOT_GITHUB_TOKEN", // Defaults to copilot
56 expectNil: false,
57 },
58 }
59
60 for _, tt := range tests {
61 t.Run(tt.name, func(t *testing.T) {
62 // Create workflow file with unique name
63 workflowPath := filepath.Join(workflowsDir, tt.name+".md")
64 err := os.WriteFile(workflowPath, []byte(tt.workflowContent), 0644)
65 require.NoError(t, err, "Should write workflow file")
66 defer os.Remove(workflowPath)
67
68 // Test the function
69 secrets := getSecretRequirementsForWorkflow(workflowPath)
70
71 if tt.expectNil {
72 assert.Nil(t, secrets, "Should return nil for workflow without engine")
73 } else {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected