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

Function TestPreviewOrphanedIncludes

pkg/cli/commands_test.go:688–829  ·  view source on GitHub ↗

TestPreviewOrphanedIncludes tests the preview functionality for orphaned includes

(t *testing.T)

Source from the content-addressed store, hash-verified

686
687// TestPreviewOrphanedIncludes tests the preview functionality for orphaned includes
688func TestPreviewOrphanedIncludes(t *testing.T) {
689 // Create a temporary directory structure
690 tmpDir, err := os.MkdirTemp("", "test-preview-orphaned")
691 if err != nil {
692 t.Fatal(err)
693 }
694 defer os.RemoveAll(tmpDir)
695
696 // Create .github/workflows directory
697 workflowsDir := filepath.Join(tmpDir, constants.GetWorkflowDir())
698 if err := os.MkdirAll(workflowsDir, 0755); err != nil {
699 t.Fatal(err)
700 }
701
702 // Create shared subdirectory
703 sharedDir := filepath.Join(workflowsDir, "shared")
704 if err := os.MkdirAll(sharedDir, 0755); err != nil {
705 t.Fatal(err)
706 }
707
708 // Create workflow files
709 workflow1 := `---
710on:
711 workflow_dispatch:
712---
713
714# Workflow 1
715
716@include shared/common.md
717
718This workflow uses common include.
719`
720 if err := os.WriteFile(filepath.Join(workflowsDir, "workflow1.md"), []byte(workflow1), 0644); err != nil {
721 t.Fatal(err)
722 }
723
724 workflow2 := `---
725on:
726 workflow_dispatch:
727---
728
729# Workflow 2
730
731@include shared/tools.md
732
733This workflow uses tools include.
734`
735 if err := os.WriteFile(filepath.Join(workflowsDir, "workflow2.md"), []byte(workflow2), 0644); err != nil {
736 t.Fatal(err)
737 }
738
739 workflow3 := `---
740on:
741 workflow_dispatch:
742---
743
744# Workflow 3
745

Callers

nothing calls this directly

Calls 4

GetWorkflowDirFunction · 0.92
previewOrphanedIncludesFunction · 0.85
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected