(t *testing.T)
| 448 | } |
| 449 | |
| 450 | func TestGetWorkflowLockFileName(t *testing.T) { |
| 451 | workflowsDir := setupWorkflowDir(t) |
| 452 | |
| 453 | // Create sample workflow files |
| 454 | testWorkflows := map[string]string{ |
| 455 | "smoke-copilot": "Smoke Copilot", |
| 456 | "weekly-plan": "Weekly Plan", |
| 457 | } |
| 458 | for workflowID, displayName := range testWorkflows { |
| 459 | mdFile := filepath.Join(workflowsDir, workflowID+".md") |
| 460 | lockFile := filepath.Join(workflowsDir, workflowID+".lock.yml") |
| 461 | |
| 462 | require.NoError(t, os.WriteFile(mdFile, []byte("# "+workflowID+"\nSome content"), 0644), "failed to write workflow markdown file") |
| 463 | |
| 464 | lockContent := "name: \"" + displayName + "\"\non: push\n" |
| 465 | require.NoError(t, os.WriteFile(lockFile, []byte(lockContent), 0644), "failed to write workflow lock file") |
| 466 | } |
| 467 | |
| 468 | tests := []struct { |
| 469 | name string |
| 470 | input string |
| 471 | expectedFile string |
| 472 | expectError bool |
| 473 | }{ |
| 474 | { |
| 475 | name: "workflow ID", |
| 476 | input: "smoke-copilot", |
| 477 | expectedFile: "smoke-copilot.lock.yml", |
| 478 | }, |
| 479 | { |
| 480 | name: "workflow ID with .md extension", |
| 481 | input: "smoke-copilot.md", |
| 482 | expectedFile: "smoke-copilot.lock.yml", |
| 483 | }, |
| 484 | { |
| 485 | name: "workflow ID with .lock.yml extension", |
| 486 | input: "smoke-copilot.lock.yml", |
| 487 | expectedFile: "smoke-copilot.lock.yml", |
| 488 | }, |
| 489 | { |
| 490 | name: "display name exact match", |
| 491 | input: "Smoke Copilot", |
| 492 | expectedFile: "smoke-copilot.lock.yml", |
| 493 | }, |
| 494 | { |
| 495 | name: "display name case-insensitive match", |
| 496 | input: "smoke copilot", |
| 497 | expectedFile: "smoke-copilot.lock.yml", |
| 498 | }, |
| 499 | { |
| 500 | name: "non-existent workflow", |
| 501 | input: "non-existent", |
| 502 | expectError: true, |
| 503 | }, |
| 504 | { |
| 505 | name: "empty input", |
| 506 | input: "", |
| 507 | expectedFile: "", |
nothing calls this directly
no test coverage detected