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

Function TestFixCommand_UpdatesPromptAndAgentFiles

pkg/cli/fix_command_test.go:694–755  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

692}
693
694func TestFixCommand_UpdatesPromptAndAgentFiles(t *testing.T) {
695 if _, err := exec.LookPath("git"); err != nil {
696 // Skip when git isn't available in the test environment.
697 t.Skip("Git not available")
698 }
699
700 // Create a temporary directory for test files
701 tmpDir := t.TempDir()
702 workflowFile := filepath.Join(tmpDir, "test-workflow.md")
703
704 // Save and restore original directory
705 originalDir, err := os.Getwd()
706 require.NoError(t, err, "Failed to get current directory")
707 t.Cleanup(func() {
708 if chdirErr := os.Chdir(originalDir); chdirErr != nil {
709 t.Errorf("Failed to restore current directory: %v", chdirErr)
710 }
711 })
712
713 require.NoError(t, os.Chdir(tmpDir), "Failed to change to temp directory")
714
715 // Initialize git repo (required for ensure functions)
716 require.NoError(t, exec.Command("git", "init").Run(), "Failed to initialize git repo")
717
718 // Configure git
719 require.NoError(t, exec.Command("git", "config", "user.name", "Test User").Run(), "Failed to configure git user.name")
720 require.NoError(t, exec.Command("git", "config", "user.email", "test@example.com").Run(), "Failed to configure git user.email")
721
722 // Create a simple workflow file (no fixes needed)
723 content := `---
724on:
725 workflow_dispatch:
726
727permissions:
728 contents: read
729---
730
731# Test Workflow
732
733This is a test workflow.
734`
735
736 require.NoError(t, os.WriteFile(workflowFile, []byte(content), 0644), "Failed to create test file")
737
738 // Run fix command (which refreshes the generated skill and agent files)
739 config := FixConfig{
740 WorkflowIDs: []string{"test-workflow"},
741 Write: false,
742 Verbose: false,
743 WorkflowDir: tmpDir,
744 }
745
746 require.NoError(t, RunFix(config), "RunFix failed")
747
748 _, err = os.Stat(filepath.Join(tmpDir, ".github", "skills", "agentic-workflows", "SKILL.md"))
749 require.NoError(t, err, "Expected generated skill file to exist after RunFix")
750
751 agentContent, err := os.ReadFile(filepath.Join(tmpDir, ".github", "agents", "agentic-workflows.md"))

Callers

nothing calls this directly

Calls 3

RunFixFunction · 0.85
ErrorfMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected