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

Function TestCleanCmd_Completion

cmds/cmd_clean_test.go:177–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestCleanCmd_Completion(t *testing.T) {
178 // Cleanup.
179 dirs.RemoveAllForTest()
180
181 // Setup test environment.
182 os.MkdirAll(dirs.BuildtreesDir, os.ModePerm)
183 os.MkdirAll(dirs.ConfProjectsDir, os.ModePerm)
184
185 // Create test buildtrees.
186 os.MkdirAll(filepath.Join(dirs.BuildtreesDir, "x264@stable"), os.ModePerm)
187 os.MkdirAll(filepath.Join(dirs.BuildtreesDir, "ffmpeg@3.4.13"), os.ModePerm)
188
189 // Create test projects.
190 os.WriteFile(filepath.Join(dirs.ConfProjectsDir, "project1.toml"), []byte{}, 0644)
191 os.WriteFile(filepath.Join(dirs.ConfProjectsDir, "project2.toml"), []byte{}, 0644)
192
193 cleanCmd := cleanCmd{}
194 celer := configs.NewCeler()
195 cmd := cleanCmd.Command(celer)
196
197 tests := []struct {
198 name string
199 toComplete string
200 expectContain []string
201 }{
202 {
203 name: "complete_package_prefix",
204 toComplete: "x264",
205 expectContain: []string{"x264@stable"},
206 },
207 {
208 name: "complete_project_prefix",
209 toComplete: "project",
210 expectContain: []string{"project1", "project2"},
211 },
212 {
213 name: "complete_dev_flag",
214 toComplete: "--d",
215 expectContain: []string{"--dev"},
216 },
217 {
218 name: "complete_dev_short_flag",
219 toComplete: "-d",
220 expectContain: []string{"-d"},
221 },
222 {
223 name: "complete_recursive_flag",
224 toComplete: "--r",
225 expectContain: []string{"--recursive"},
226 },
227 {
228 name: "complete_all_flag",
229 toComplete: "--a",
230 expectContain: []string{"--all"},
231 },
232 {
233 name: "no_match",
234 toComplete: "nonexistent",

Callers

nothing calls this directly

Calls 6

CommandMethod · 0.95
completionMethod · 0.95
RemoveAllForTestFunction · 0.92
NewCelerFunction · 0.92
MkdirAllMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected