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

Function TestInitCmd_Command

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

Source from the content-addressed store, hash-verified

121}
122
123func 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
169func TestInitCmd_Initialize(t *testing.T) {
170 // `celer init` without --url must fail at cobra's required-flag check,

Callers

nothing calls this directly

Calls 3

PathExistsFunction · 0.92
runInitFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected