MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestInitCmd_EdgeCases

Function TestInitCmd_EdgeCases

cmds/cmd_init_test.go:207–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

205}
206
207func TestInitCmd_EdgeCases(t *testing.T) {
208 tests := []struct {
209 name string
210 args []string
211 expectError bool
212 description string
213 }{
214 {
215 name: "branch_with_master",
216 args: []string{"--url=" + test_conf_repo_url, "--branch=master"},
217 expectError: false,
218 description: "Should succeed with existing branch",
219 },
220 {
221 name: "branch_nonexistent",
222 args: []string{"--url=" + test_conf_repo_url, "--branch=does-not-exist-9999"},
223 expectError: true,
224 description: "Should fail when branch does not exist on remote",
225 },
226 {
227 name: "url_not_a_git_repo",
228 args: []string{"--url=https://example.com/not-a-repo.git"},
229 expectError: true,
230 description: "Should fail when URL is not a real git repository",
231 },
232 }
233
234 for _, test := range tests {
235 t.Run(test.name, func(t *testing.T) {
236 stderr, err := runInit(t, test.args...)
237 if test.expectError && err == nil {
238 t.Errorf("%s: expected error, got none\nstderr:\n%s", test.description, stderr)
239 }
240 if !test.expectError && err != nil {
241 t.Errorf("%s: unexpected error: %v\nstderr:\n%s", test.description, err, stderr)
242 }
243 })
244 }
245}
246
247// Verify trim behavior: leading/trailing spaces in --url should still be
248// handled by RunE's strings.TrimSpace before reaching CloneConf.

Callers

nothing calls this directly

Calls 1

runInitFunction · 0.85

Tested by

no test coverage detected