(t *testing.T)
| 339 | } |
| 340 | |
| 341 | func TestIsRunnable_RealWorldScenario(t *testing.T) { |
| 342 | // This test simulates the real-world scenario from the issue: |
| 343 | // A workflow with "on: daily" in the .md file gets compiled to |
| 344 | // include workflow_dispatch in the .lock.yml file |
| 345 | tmpDir := t.TempDir() |
| 346 | markdownPath := filepath.Join(tmpDir, "daily-issues-report.md") |
| 347 | lockPath := getLockFilePath(markdownPath) |
| 348 | |
| 349 | // Create markdown file with shorthand trigger |
| 350 | markdownContent := `--- |
| 351 | description: Daily report |
| 352 | on: daily |
| 353 | permissions: |
| 354 | contents: read |
| 355 | engine: codex |
| 356 | --- |
| 357 | |
| 358 | # Daily Issues Report |
| 359 | ` |
| 360 | err := os.WriteFile(markdownPath, []byte(markdownContent), 0644) |
| 361 | require.NoError(t, err) |
| 362 | |
| 363 | // Create lock file with expanded triggers (as the compiler would do) |
| 364 | lockContent := `name: "Daily Issues Report Generator" |
| 365 | on: |
| 366 | schedule: |
| 367 | - cron: "10 16 * * *" |
| 368 | workflow_dispatch: |
| 369 | |
| 370 | permissions: |
| 371 | contents: read |
| 372 | |
| 373 | jobs: |
| 374 | agent: |
| 375 | runs-on: ubuntu-latest |
| 376 | steps: |
| 377 | - run: echo "test" |
| 378 | ` |
| 379 | err = os.WriteFile(lockPath, []byte(lockContent), 0644) |
| 380 | require.NoError(t, err) |
| 381 | |
| 382 | // Test that the workflow is runnable |
| 383 | runnable, err := IsRunnable(markdownPath) |
| 384 | require.NoError(t, err, "Should not error when checking compiled workflow") |
| 385 | assert.True(t, runnable, "Workflow should be runnable because lock file has workflow_dispatch") |
| 386 | } |
| 387 | |
| 388 | func TestValidateWorkflowInputs_WithLockFile(t *testing.T) { |
| 389 | // This test ensures validateWorkflowInputs still works with lock files |
nothing calls this directly
no test coverage detected