TestPreviewOrphanedIncludes tests the preview functionality for orphaned includes
(t *testing.T)
| 686 | |
| 687 | // TestPreviewOrphanedIncludes tests the preview functionality for orphaned includes |
| 688 | func 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 := `--- |
| 710 | on: |
| 711 | workflow_dispatch: |
| 712 | --- |
| 713 | |
| 714 | # Workflow 1 |
| 715 | |
| 716 | @include shared/common.md |
| 717 | |
| 718 | This 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 := `--- |
| 725 | on: |
| 726 | workflow_dispatch: |
| 727 | --- |
| 728 | |
| 729 | # Workflow 2 |
| 730 | |
| 731 | @include shared/tools.md |
| 732 | |
| 733 | This 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 := `--- |
| 740 | on: |
| 741 | workflow_dispatch: |
| 742 | --- |
| 743 | |
| 744 | # Workflow 3 |
| 745 |
nothing calls this directly
no test coverage detected