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

Function TestInitRepositoryWithMCP

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

Source from the content-addressed store, hash-verified

268}
269
270func TestInitRepositoryWithMCP(t *testing.T) {
271 tmpDir := testutil.TempDir(t, "test-*")
272
273 originalDir, err := os.Getwd()
274 if err != nil {
275 t.Fatalf("Failed to get current directory: %v", err)
276 }
277 defer func() {
278 _ = os.Chdir(originalDir)
279 }()
280
281 if err := os.Chdir(tmpDir); err != nil {
282 t.Fatalf("Failed to change to temp directory: %v", err)
283 }
284
285 // Initialize git repo
286 if err := exec.Command("git", "init").Run(); err != nil {
287 t.Skip("Git not available")
288 }
289
290 // Configure git
291 exec.Command("git", "config", "user.name", "Test User").Run()
292 exec.Command("git", "config", "user.email", "test@example.com").Run()
293
294 // Test init with MCP explicitly enabled (same as default)
295 err = InitRepository(InitOptions{Verbose: false, Skill: true, Agent: true, MCP: true, CodespaceRepos: []string{}, CodespaceEnabled: false, Completions: false, CreatePR: false, RootCmd: nil})
296 if err != nil {
297 t.Fatalf("InitRepository(, false, false, false, nil) with MCP failed: %v", err)
298 }
299
300 // Verify .github/mcp.json was created
301 mcpConfigPath := mcpConfigFilePath
302 if _, err := os.Stat(mcpConfigPath); os.IsNotExist(err) {
303 t.Error("Expected .github/mcp.json to be created")
304 }
305
306 // Verify copilot-setup-steps.yml was created
307 setupStepsPath := filepath.Join(".github", "workflows", "copilot-setup-steps.yml")
308 if _, err := os.Stat(setupStepsPath); os.IsNotExist(err) {
309 t.Error("Expected .github/workflows/copilot-setup-steps.yml to be created")
310 }
311}
312
313func TestInitRepositoryWithNoMCP(t *testing.T) {
314 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