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

Function TestInitRepositoryNotInGitRepo

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

Source from the content-addressed store, hash-verified

618}
619
620func TestInitRepositoryNotInGitRepo(t *testing.T) {
621 tmpDir := testutil.TempDir(t, "test-*")
622
623 originalDir, err := os.Getwd()
624 if err != nil {
625 t.Fatalf("Failed to get current directory: %v", err)
626 }
627 defer func() {
628 _ = os.Chdir(originalDir)
629 }()
630
631 if err := os.Chdir(tmpDir); err != nil {
632 t.Fatalf("Failed to change to temp directory: %v", err)
633 }
634
635 // Don't initialize git repo - should fail for some operations
636 err = InitRepository(InitOptions{Verbose: false, Skill: true, Agent: true, MCP: true, CodespaceRepos: []string{}, CodespaceEnabled: false, Completions: false, CreatePR: false, RootCmd: nil})
637
638 // The function should handle this gracefully or return an error
639 // Based on the implementation, ensureGitAttributes requires git
640 if err == nil {
641 t.Log("InitRepository(, false, false, false, nil) succeeded despite not being in a git repo")
642 }
643}
644
645func TestInitRepositoryIdempotent(t *testing.T) {
646 tmpDir := testutil.TempDir(t, "test-*")

Callers

nothing calls this directly

Calls 2

TempDirFunction · 0.92
InitRepositoryFunction · 0.85

Tested by

no test coverage detected