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

Function TestCopilotEngineExecutionSteps

pkg/workflow/copilot_engine_test.go:127–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestCopilotEngineExecutionSteps(t *testing.T) {
128 engine := NewCopilotEngine()
129 workflowData := &WorkflowData{
130 Name: "test-workflow",
131 }
132 steps := engine.GetExecutionSteps(workflowData, "/tmp/gh-aw/test.log")
133
134 // GetExecutionSteps returns 1 step: copilot execution
135 if len(steps) != 1 {
136 t.Fatalf("Expected 1 execution step, got %d", len(steps))
137 }
138
139 // Check the execution step
140 stepContent := strings.Join([]string(steps[0]), "\n")
141
142 if !strings.Contains(stepContent, "name: Execute GitHub Copilot CLI") {
143 t.Errorf("Expected step name 'Execute GitHub Copilot CLI' in step content:\n%s", stepContent)
144 }
145
146 // When firewall is disabled, should use 'copilot' command (not npx)
147 if !strings.Contains(stepContent, "copilot") || !strings.Contains(stepContent, "--add-dir /tmp/ --add-dir /tmp/gh-aw/ --add-dir /tmp/gh-aw/agent/ --log-level all --log-dir") {
148 t.Errorf("Expected command to contain 'copilot' and '--add-dir /tmp/ --add-dir /tmp/gh-aw/ --add-dir /tmp/gh-aw/agent/ --log-level all --log-dir' in step content:\n%s", stepContent)
149 }
150
151 if !strings.Contains(stepContent, "/tmp/gh-aw/test.log") {
152 t.Errorf("Expected command to contain log file name in step content:\n%s", stepContent)
153 }
154
155 if !strings.Contains(stepContent, "--prompt-file /tmp/gh-aw/aw-prompts/prompt.txt") {
156 t.Errorf("Expected command to pass prompt file path directly, got:\n%s", stepContent)
157 }
158 if strings.Contains(stepContent, `cd "${GITHUB_WORKSPACE}" &&`) {
159 t.Errorf("Expected Copilot command to not use shell cd prefix (harness sets cwd via spawn options), got:\n%s", stepContent)
160 }
161
162 if strings.Contains(stepContent, "COPILOT_CLI_INSTRUCTION=") {
163 t.Errorf("Expected command to avoid loading prompt into shell variable, got:\n%s", stepContent)
164 }
165
166 if !strings.Contains(stepContent, "COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}") {
167 t.Errorf("Expected COPILOT_GITHUB_TOKEN environment variable in step content:\n%s", stepContent)
168 }
169
170 if !strings.Contains(stepContent, constants.CopilotCLIIntegrationIDEnvVar+": "+constants.CopilotCLIIntegrationIDValue) {
171 t.Errorf("Expected %s environment variable in step content:\n%s", constants.CopilotCLIIntegrationIDEnvVar, stepContent)
172 }
173
174 // Test that GITHUB_HEAD_REF and GITHUB_REF_NAME are present for branch resolution
175 if !strings.Contains(stepContent, "GITHUB_HEAD_REF: ${{ github.head_ref }}") {
176 t.Errorf("Expected GITHUB_HEAD_REF environment variable in step content:\n%s", stepContent)
177 }
178
179 if !strings.Contains(stepContent, "GITHUB_REF_NAME: ${{ github.ref_name }}") {
180 t.Errorf("Expected GITHUB_REF_NAME environment variable in step content:\n%s", stepContent)
181 }
182
183 if !strings.Contains(stepContent, "GITHUB_WORKSPACE: ${{ github.workspace }}") {
184 t.Errorf("Expected GITHUB_WORKSPACE environment variable in step content:\n%s", stepContent)

Callers

nothing calls this directly

Calls 4

GetExecutionStepsMethod · 0.95
NewCopilotEngineFunction · 0.85
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected