MCPcopy Create free account
hub / github.com/github/gh-aw / TestAddWorkflowWithCustomName

Function TestAddWorkflowWithCustomName

pkg/cli/add_integration_test.go:405–450  ·  view source on GitHub ↗

TestAddWorkflowWithCustomName tests adding a workflow with a custom name

(t *testing.T)

Source from the content-addressed store, hash-verified

403
404// TestAddWorkflowWithCustomName tests adding a workflow with a custom name
405func 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 := `---
416name: Original Workflow
417on: workflow_dispatch
418permissions:
419 contents: read
420engine: copilot
421---
422
423# Original Workflow
424
425Test 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
453func TestAddWorkflowToCustomDir(t *testing.T) {

Callers

nothing calls this directly

Calls 1

setupAddIntegrationTestFunction · 0.85

Tested by

no test coverage detected