TestAddWorkflowWithCustomName tests adding a workflow with a custom name
(t *testing.T)
| 403 | |
| 404 | // TestAddWorkflowWithCustomName tests adding a workflow with a custom name |
| 405 | func TestAddWorkflowWithCustomName(t *testing.T) { |
| 406 | setup := setupAddIntegrationTest(t) |
| 407 | defer setup.cleanup() |
| 408 | |
| 409 | // Create a local workflow file |
| 410 | sourceDir := filepath.Join(setup.tempDir, "source-workflows") |
| 411 | err := os.MkdirAll(sourceDir, 0755) |
| 412 | require.NoError(t, err, "should create source directory") |
| 413 | |
| 414 | localWorkflowPath := filepath.Join(sourceDir, "original-name.md") |
| 415 | localWorkflowContent := `--- |
| 416 | name: Original Workflow |
| 417 | on: workflow_dispatch |
| 418 | permissions: |
| 419 | contents: read |
| 420 | engine: copilot |
| 421 | --- |
| 422 | |
| 423 | # Original Workflow |
| 424 | |
| 425 | Test content. |
| 426 | ` |
| 427 | err = os.WriteFile(localWorkflowPath, []byte(localWorkflowContent), 0644) |
| 428 | require.NoError(t, err, "should write local workflow file") |
| 429 | |
| 430 | // Add with a custom name |
| 431 | cmd := exec.Command(setup.binaryPath, "add", localWorkflowPath, "--name", "custom-workflow-name") |
| 432 | cmd.Dir = setup.tempDir |
| 433 | output, err := cmd.CombinedOutput() |
| 434 | outputStr := string(output) |
| 435 | |
| 436 | t.Logf("Command output:\n%s", outputStr) |
| 437 | |
| 438 | require.NoError(t, err, "add command should succeed: %s", outputStr) |
| 439 | |
| 440 | // Verify the workflow file was created with custom name |
| 441 | workflowsDir := filepath.Join(setup.tempDir, ".github", "workflows") |
| 442 | customWorkflowFile := filepath.Join(workflowsDir, "custom-workflow-name.md") |
| 443 | _, err = os.Stat(customWorkflowFile) |
| 444 | require.NoError(t, err, "workflow file with custom name should exist: %s", customWorkflowFile) |
| 445 | |
| 446 | // Verify original name file does NOT exist |
| 447 | originalNameFile := filepath.Join(workflowsDir, "original-name.md") |
| 448 | _, err = os.Stat(originalNameFile) |
| 449 | assert.True(t, os.IsNotExist(err), "original name file should NOT exist") |
| 450 | } |
| 451 | |
| 452 | // TestAddWorkflowToCustomDir tests adding a workflow to a custom subdirectory |
| 453 | func TestAddWorkflowToCustomDir(t *testing.T) { |
nothing calls this directly
no test coverage detected