TestCollectWorkflowFiles_NoLockFile tests that when a workflow has no lock file, the collectWorkflowFiles function compiles the workflow and creates one. This is an integration test because it invokes the full workflow compilation.
(t *testing.T)
| 17 | // the collectWorkflowFiles function compiles the workflow and creates one. |
| 18 | // This is an integration test because it invokes the full workflow compilation. |
| 19 | func TestCollectWorkflowFiles_NoLockFile(t *testing.T) { |
| 20 | |
| 21 | // Create a temporary directory for testing |
| 22 | tmpDir := t.TempDir() |
| 23 | |
| 24 | // Create a simple workflow file without a lock file |
| 25 | workflowPath := filepath.Join(tmpDir, "test-workflow.md") |
| 26 | workflowContent := `--- |
| 27 | name: Test Workflow |
| 28 | on: workflow_dispatch |
| 29 | --- |
| 30 | # Test Workflow |
| 31 | This is a test workflow without a lock file. |
| 32 | ` |
| 33 | err := os.WriteFile(workflowPath, []byte(workflowContent), 0644) |
| 34 | require.NoError(t, err) |
| 35 | |
| 36 | // Test collecting files - should now compile the workflow and create lock file |
| 37 | files, err := collectWorkflowFiles(context.Background(), workflowPath, false, false) |
| 38 | require.NoError(t, err) |
| 39 | assert.Len(t, files, 2, "Should collect workflow .md file and auto-generate lock file") |
| 40 | |
| 41 | // Check that both workflow file and lock file are in the result |
| 42 | fileSet := make(map[string]bool) |
| 43 | for _, file := range files { |
| 44 | fileSet[file] = true |
| 45 | } |
| 46 | assert.True(t, fileSet[workflowPath], "Should include workflow .md file") |
| 47 | |
| 48 | lockFilePath := stringutil.MarkdownToLockFile(workflowPath) |
| 49 | assert.True(t, fileSet[lockFilePath], "Should include auto-generated lock .yml file") |
| 50 | } |
nothing calls this directly
no test coverage detected