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

Function TestAddWorkflowToCustomDir

pkg/cli/add_integration_test.go:453–502  ·  view source on GitHub ↗

TestAddWorkflowToCustomDir tests adding a workflow to a custom subdirectory

(t *testing.T)

Source from the content-addressed store, hash-verified

451
452// TestAddWorkflowToCustomDir tests adding a workflow to a custom subdirectory
453func TestAddWorkflowToCustomDir(t *testing.T) {
454 setup := setupAddIntegrationTest(t)
455 defer setup.cleanup()
456
457 // Create a local workflow file
458 sourceDir := filepath.Join(setup.tempDir, "source-workflows")
459 err := os.MkdirAll(sourceDir, 0755)
460 require.NoError(t, err, "should create source directory")
461
462 localWorkflowPath := filepath.Join(sourceDir, "test-workflow.md")
463 localWorkflowContent := `---
464name: Test Workflow
465on: workflow_dispatch
466permissions:
467 contents: read
468engine: copilot
469---
470
471# Test Workflow
472
473Test content.
474`
475 err = os.WriteFile(localWorkflowPath, []byte(localWorkflowContent), 0644)
476 require.NoError(t, err, "should write local workflow file")
477
478 // Add to a custom directory (full path required, consistent with compile/fix/upgrade --dir)
479 cmd := exec.Command(setup.binaryPath, "add", localWorkflowPath, "--dir", ".github/workflows/experimental")
480 cmd.Dir = setup.tempDir
481 output, err := cmd.CombinedOutput()
482 outputStr := string(output)
483
484 t.Logf("Command output:\n%s", outputStr)
485
486 require.NoError(t, err, "add command should succeed: %s", outputStr)
487
488 // Verify the workflow file was created in the custom directory
489 customDir := filepath.Join(setup.tempDir, ".github", "workflows", "experimental")
490 info, err := os.Stat(customDir)
491 require.NoError(t, err, "custom workflows subdirectory should exist")
492 assert.True(t, info.IsDir(), "should be a directory")
493
494 workflowFile := filepath.Join(customDir, "test-workflow.md")
495 _, err = os.Stat(workflowFile)
496 require.NoError(t, err, "workflow file should exist in custom directory: %s", workflowFile)
497
498 // Verify the lock file is also in the custom directory
499 lockFile := filepath.Join(customDir, "test-workflow.lock.yml")
500 _, err = os.Stat(lockFile)
501 require.NoError(t, err, "lock file should exist in custom directory: %s", lockFile)
502}
503
504// TestAddWorkflowForce tests the --force flag to overwrite existing workflows
505func TestAddWorkflowForce(t *testing.T) {

Callers

nothing calls this directly

Calls 1

setupAddIntegrationTestFunction · 0.85

Tested by

no test coverage detected