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

Function TestEnsureCopilotSetupStepsDirectoryCreation

pkg/cli/copilot_setup_test.go:395–433  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

393}
394
395func TestEnsureCopilotSetupStepsDirectoryCreation(t *testing.T) {
396 tmpDir := testutil.TempDir(t, "test-*")
397
398 originalDir, err := os.Getwd()
399 if err != nil {
400 t.Fatalf("Failed to get current directory: %v", err)
401 }
402 defer func() {
403 _ = os.Chdir(originalDir)
404 }()
405
406 if err := os.Chdir(tmpDir); err != nil {
407 t.Fatalf("Failed to change to temp directory: %v", err)
408 }
409
410 // Call function when .github/workflows doesn't exist
411 err = ensureCopilotSetupSteps(context.Background(), false, workflow.ActionModeDev, "dev")
412 if err != nil {
413 t.Fatalf("ensureCopilotSetupSteps(context.Background()) failed: %v", err)
414 }
415
416 // Verify directory structure was created
417 workflowsDir := filepath.Join(".github", "workflows")
418 info, err := os.Stat(workflowsDir)
419 if os.IsNotExist(err) {
420 t.Error("Expected .github/workflows directory to be created")
421 return
422 }
423
424 if !info.IsDir() {
425 t.Error("Expected .github/workflows to be a directory")
426 }
427
428 // Verify file was created
429 setupStepsPath := filepath.Join(workflowsDir, "copilot-setup-steps.yml")
430 if _, err := os.Stat(setupStepsPath); os.IsNotExist(err) {
431 t.Error("Expected copilot-setup-steps.yml to be created")
432 }
433}
434
435// TestEnsureCopilotSetupSteps_ReleaseMode tests that release mode uses the actions/setup-cli action
436func TestEnsureCopilotSetupSteps_ReleaseMode(t *testing.T) {

Callers

nothing calls this directly

Calls 4

TempDirFunction · 0.92
ensureCopilotSetupStepsFunction · 0.85
BackgroundMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected