TestInitRepository_WithNilRootCmd verifies that InitRepository handles nil rootCmd gracefully
(t *testing.T)
| 50 | |
| 51 | // TestInitRepository_WithNilRootCmd verifies that InitRepository handles nil rootCmd gracefully |
| 52 | func TestInitRepository_WithNilRootCmd(t *testing.T) { |
| 53 | // Create a temporary git repository |
| 54 | tempDir := testutil.TempDir(t, "test-*") |
| 55 | |
| 56 | // Change to the temp directory |
| 57 | oldWd, err := os.Getwd() |
| 58 | require.NoError(t, err, "Failed to get current directory") |
| 59 | defer func() { |
| 60 | _ = os.Chdir(oldWd) |
| 61 | }() |
| 62 | err = os.Chdir(tempDir) |
| 63 | require.NoError(t, err, "Failed to change directory") |
| 64 | |
| 65 | // Initialize git repo |
| 66 | err = exec.Command("git", "init").Run() |
| 67 | require.NoError(t, err, "Failed to init git repo") |
| 68 | |
| 69 | // InitRepository with nil rootCmd and completions disabled should succeed |
| 70 | err = InitRepository(InitOptions{Verbose: false, Skill: true, Agent: true, MCP: false, CodespaceRepos: []string{}, CodespaceEnabled: false, Completions: false, CreatePR: false, RootCmd: nil}) |
| 71 | require.NoError(t, err, "InitRepository with nil rootCmd should succeed when completions are disabled") |
| 72 | } |
| 73 | |
| 74 | // TestInitRepository_WithRootCmd verifies that InitRepository works with a real rootCmd |
| 75 | func TestInitRepository_WithRootCmd(t *testing.T) { |
nothing calls this directly
no test coverage detected