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

Function TestInstallCmd_ErrorHandling

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

Source from the content-addressed store, hash-verified

354}
355
356func TestInstallCmd_ErrorHandling(t *testing.T) {
357 // Cleanup.
358 dirs.RemoveAllForTest()
359
360 tests := []struct {
361 name string
362 input string
363 expectError string
364 }{
365 {
366 name: "empty package name",
367 input: "",
368 expectError: "package name cannot be empty",
369 },
370 {
371 name: "invalid format - no version",
372 input: "opencv",
373 expectError: "package must be specified in name@version format",
374 },
375 {
376 name: "invalid format - empty name",
377 input: "@4.8.0",
378 expectError: "package name cannot be empty",
379 },
380 {
381 name: "invalid format - empty version",
382 input: "opencv@",
383 expectError: "package version cannot be empty",
384 },
385 }
386
387 installCmd := &installCmd{}
388 for _, test := range tests {
389 t.Run(test.name, func(t *testing.T) {
390 _, err := installCmd.validateAndCleanInput(test.input)
391 if err == nil {
392 t.Errorf("Expected error for input '%s' but got none", test.input)
393 return
394 }
395
396 if !strings.Contains(err.Error(), test.expectError) {
397 t.Errorf("Expected error containing '%s' for input '%s', got: %v", test.expectError, test.input, err)
398 }
399 })
400 }
401}
402
403func TestInstallCmd_RunInstall_MultiPackages_PreInitValidation(t *testing.T) {
404 installCmd := &installCmd{}

Callers

nothing calls this directly

Calls 3

validateAndCleanInputMethod · 0.95
RemoveAllForTestFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected