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

Function TestInitRepositoryWithMCPBackwardCompatibility

pkg/cli/init_command_test.go:541–582  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

539}
540
541func TestInitRepositoryWithMCPBackwardCompatibility(t *testing.T) {
542 tmpDir := testutil.TempDir(t, "test-*")
543
544 originalDir, err := os.Getwd()
545 if err != nil {
546 t.Fatalf("Failed to get current directory: %v", err)
547 }
548 defer func() {
549 _ = os.Chdir(originalDir)
550 }()
551
552 if err := os.Chdir(tmpDir); err != nil {
553 t.Fatalf("Failed to change to temp directory: %v", err)
554 }
555
556 // Initialize git repo
557 if err := exec.Command("git", "init").Run(); err != nil {
558 t.Skip("Git not available")
559 }
560
561 // Configure git
562 exec.Command("git", "config", "user.name", "Test User").Run()
563 exec.Command("git", "config", "user.email", "test@example.com").Run()
564
565 // Test init with deprecated --mcp flag for backward compatibility (mcp=true)
566 err = InitRepository(InitOptions{Verbose: false, Skill: true, Agent: true, MCP: true, CodespaceRepos: []string{}, CodespaceEnabled: false, Completions: false, CreatePR: false, RootCmd: nil})
567 if err != nil {
568 t.Fatalf("InitRepository(, false, false, false, nil) with deprecated --mcp flag failed: %v", err)
569 }
570
571 // Verify .github/mcp.json was created
572 mcpConfigPath := mcpConfigFilePath
573 if _, err := os.Stat(mcpConfigPath); os.IsNotExist(err) {
574 t.Error("Expected .github/mcp.json to be created with --mcp flag (backward compatibility)")
575 }
576
577 // Verify copilot-setup-steps.yml was created
578 setupStepsPath := filepath.Join(".github", "workflows", "copilot-setup-steps.yml")
579 if _, err := os.Stat(setupStepsPath); os.IsNotExist(err) {
580 t.Error("Expected .github/workflows/copilot-setup-steps.yml to be created with --mcp flag (backward compatibility)")
581 }
582}
583
584func TestInitRepositoryVerbose(t *testing.T) {
585 tmpDir := testutil.TempDir(t, "test-*")

Callers

nothing calls this directly

Calls 4

TempDirFunction · 0.92
InitRepositoryFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected