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

Function TestCopilotEngineHarnessScript

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

Source from the content-addressed store, hash-verified

2599}
2600
2601func TestCopilotEngineHarnessScript(t *testing.T) {
2602 engine := NewCopilotEngine()
2603
2604 t.Run("GetHarnessScriptName returns copilot_harness.cjs", func(t *testing.T) {
2605 if engine.GetHarnessScriptName() != "copilot_harness.cjs" {
2606 t.Errorf("Expected 'copilot_harness.cjs', got '%s'", engine.GetHarnessScriptName())
2607 }
2608 })
2609
2610 t.Run("Execution step uses driver in non-sandbox mode", func(t *testing.T) {
2611 workflowData := &WorkflowData{
2612 Name: "test-workflow",
2613 EngineConfig: &EngineConfig{ID: "copilot"},
2614 Tools: make(map[string]any),
2615 SafeOutputs: nil,
2616 }
2617
2618 steps := engine.GetExecutionSteps(workflowData, "/tmp/gh-aw/agent-stdio.log")
2619 if len(steps) == 0 {
2620 t.Fatal("Expected at least one step")
2621 }
2622
2623 stepContent := strings.Join([]string(steps[0]), "\n")
2624
2625 // The driver should be used in the command
2626 if !strings.Contains(stepContent, "copilot_harness.cjs") {
2627 t.Errorf("Expected copilot_harness.cjs in execution step, got:\n%s", stepContent)
2628 }
2629 if !strings.Contains(stepContent, nodeRuntimeResolutionCommand) {
2630 t.Errorf("Expected runtime node resolution logic in execution step, got:\n%s", stepContent)
2631 }
2632
2633 // Driver should appear before the copilot args
2634 driverIdx := strings.Index(stepContent, "copilot_harness.cjs")
2635 promptIdx := strings.Index(stepContent, "--prompt")
2636 if driverIdx == -1 || promptIdx == -1 {
2637 t.Fatal("Could not find both copilot_harness.cjs and --prompt in step")
2638 }
2639 if driverIdx > promptIdx {
2640 t.Error("Expected copilot_harness.cjs to appear before --prompt")
2641 }
2642 })
2643
2644 t.Run("Execution step uses configured custom driver instead of built-in", func(t *testing.T) {
2645 workflowData := &WorkflowData{
2646 Name: "test-workflow",
2647 EngineConfig: &EngineConfig{
2648 ID: "copilot",
2649 HarnessScript: "custom_copilot_harness.cjs",
2650 },
2651 Tools: make(map[string]any),
2652 }
2653
2654 steps := engine.GetExecutionSteps(workflowData, "/tmp/gh-aw/agent-stdio.log")
2655 if len(steps) == 0 {
2656 t.Fatal("Expected at least one step")
2657 }
2658

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected