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

Function TestInstallCmd_Completion

cmds/cmd_install_command_test.go:186–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestInstallCmd_Completion(t *testing.T) {
187 // Cleanup.
188 dirs.RemoveAllForTest()
189
190 // Check error.
191 var check = func(err error) {
192 t.Helper()
193 if err != nil {
194 t.Fatal(err)
195 }
196 }
197
198 // Create mock port structure for testing completion.
199 testPortDir := dirs.GetPortDir("testlib", "1.0.0")
200 check(os.MkdirAll(testPortDir, os.ModePerm))
201
202 // Create a port.toml file
203 portFile := filepath.Join(testPortDir, "port.toml")
204 f, err := os.Create(portFile)
205 check(err)
206 f.Close()
207
208 celer := configs.NewCeler()
209 installCmd := installCmd{celer: celer}
210 cmd := installCmd.Command(celer)
211
212 tests := []struct {
213 name string
214 toComplete string
215 expectContains []string
216 }{
217 {
218 name: "package completion",
219 toComplete: "testlib",
220 expectContains: []string{"testlib@1.0.0"},
221 },
222 {
223 name: "flag completion - dev",
224 toComplete: "--dev",
225 expectContains: []string{"--dev"},
226 },
227 {
228 name: "flag completion - force",
229 toComplete: "--force",
230 expectContains: []string{"--force"},
231 },
232 {
233 name: "flag completion - short dev",
234 toComplete: "-d",
235 expectContains: []string{"-d"},
236 },
237 {
238 name: "flag completion - jobs",
239 toComplete: "--jobs",
240 expectContains: []string{"--jobs"},
241 },
242 {
243 name: "no completion for unknown",

Callers

nothing calls this directly

Calls 7

CommandMethod · 0.95
completionMethod · 0.95
RemoveAllForTestFunction · 0.92
GetPortDirFunction · 0.92
NewCelerFunction · 0.92
checkFunction · 0.85
MkdirAllMethod · 0.80

Tested by

no test coverage detected