TestAddWorkflowWithTracking_ActionWorkflow verifies that action workflow (.yml) files are copied as-is to the target directory without frontmatter processing or compilation.
(t *testing.T)
| 546 | // TestAddWorkflowWithTracking_ActionWorkflow verifies that action workflow (.yml) files are |
| 547 | // copied as-is to the target directory without frontmatter processing or compilation. |
| 548 | func TestAddWorkflowWithTracking_ActionWorkflow(t *testing.T) { |
| 549 | tempDir := testutil.TempDir(t, "test-action-workflow-*") |
| 550 | workflowsDir := setupMinimalGitRepo(t, tempDir) |
| 551 | |
| 552 | rawYML := []byte("name: CI\non: [push]\njobs:\n build:\n runs-on: ubuntu-latest\n steps: []\n") |
| 553 | |
| 554 | spec := &WorkflowSpec{ |
| 555 | RepoSpec: RepoSpec{ |
| 556 | RepoSlug: "owner/repo", |
| 557 | Version: "main", |
| 558 | }, |
| 559 | WorkflowPath: ".github/workflows/ci.yml", |
| 560 | WorkflowName: "ci", |
| 561 | } |
| 562 | sourceInfo := &FetchedWorkflow{ |
| 563 | Content: rawYML, |
| 564 | CommitSHA: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 565 | IsLocal: false, |
| 566 | SourcePath: ".github/workflows/ci.yml", |
| 567 | } |
| 568 | resolved := &ResolvedWorkflow{ |
| 569 | Spec: spec, |
| 570 | Content: rawYML, |
| 571 | SourceInfo: sourceInfo, |
| 572 | IsActionWorkflow: true, |
| 573 | } |
| 574 | |
| 575 | err := addWorkflowWithTracking(context.Background(), resolved, nil, AddOptions{}) |
| 576 | require.NoError(t, err) |
| 577 | |
| 578 | // The .yml file should be written verbatim |
| 579 | written, err := os.ReadFile(filepath.Join(workflowsDir, "ci.yml")) |
| 580 | require.NoError(t, err) |
| 581 | assert.YAMLEq(t, string(rawYML), string(written), "action workflow content should be copied verbatim") |
| 582 | |
| 583 | // No .md or .lock.yml should be created |
| 584 | _, errMD := os.Stat(filepath.Join(workflowsDir, "ci.md")) |
| 585 | assert.True(t, os.IsNotExist(errMD), "no .md file should be created for action workflows") |
| 586 | _, errLock := os.Stat(filepath.Join(workflowsDir, "ci.lock.yml")) |
| 587 | assert.True(t, os.IsNotExist(errLock), "no .lock.yml should be created for action workflows") |
| 588 | } |
| 589 | |
| 590 | // TestAddWorkflowWithTracking_ActionWorkflow_Force verifies that the --force flag overwrites |
| 591 | // an existing action workflow file. |
nothing calls this directly
no test coverage detected