(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func TestInitCmd_Command(t *testing.T) { |
| 124 | tests := []struct { |
| 125 | name string |
| 126 | args []string |
| 127 | expectError bool |
| 128 | description string |
| 129 | }{ |
| 130 | { |
| 131 | name: "valid_git_repo", |
| 132 | args: []string{"--url=" + test_conf_repo_url}, |
| 133 | expectError: false, |
| 134 | description: "Should succeed with valid git repository", |
| 135 | }, |
| 136 | { |
| 137 | name: "valid_git_repo_with_branch", |
| 138 | args: []string{"--url=" + test_conf_repo_url, "--branch=master"}, |
| 139 | expectError: false, |
| 140 | description: "Should succeed with valid git repository and specific branch", |
| 141 | }, |
| 142 | } |
| 143 | |
| 144 | for _, test := range tests { |
| 145 | t.Run(test.name, func(t *testing.T) { |
| 146 | stderr, err := runInit(t, test.args...) |
| 147 | |
| 148 | if test.expectError && err == nil { |
| 149 | t.Errorf("Expected error but got none") |
| 150 | } else if !test.expectError && err != nil { |
| 151 | t.Errorf("Expected no error but got: %v\nstderr:\n%s", err, stderr) |
| 152 | } |
| 153 | |
| 154 | // Verify that celer.toml was created. |
| 155 | celerPath := filepath.Join(dirs.WorkspaceDir, "celer.toml") |
| 156 | if !fileio.PathExists(celerPath) { |
| 157 | t.Error("celer.toml should be created after init") |
| 158 | } |
| 159 | |
| 160 | // Verify conf repo was cloned. |
| 161 | confDir := filepath.Join(dirs.WorkspaceDir, "conf") |
| 162 | if !fileio.PathExists(confDir) { |
| 163 | t.Error("conf directory should be created when URL is provided") |
| 164 | } |
| 165 | }) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func TestInitCmd_Initialize(t *testing.T) { |
| 170 | // `celer init` without --url must fail at cobra's required-flag check, |
nothing calls this directly
no test coverage detected