(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestTreeCmd_ValidateTarget(t *testing.T) { |
| 58 | // Cleanup. |
| 59 | dirs.RemoveAllForTest() |
| 60 | |
| 61 | treeCmd := treeCmd{} |
| 62 | |
| 63 | tests := []struct { |
| 64 | name string |
| 65 | target string |
| 66 | expectError bool |
| 67 | description string |
| 68 | }{ |
| 69 | { |
| 70 | name: "valid_package", |
| 71 | target: "boost@1.87.0", |
| 72 | expectError: false, |
| 73 | description: "Should accept valid package format", |
| 74 | }, |
| 75 | { |
| 76 | name: "valid_project", |
| 77 | target: "my_project", |
| 78 | expectError: false, |
| 79 | description: "Should accept valid project name", |
| 80 | }, |
| 81 | { |
| 82 | name: "empty_target", |
| 83 | target: "", |
| 84 | expectError: true, |
| 85 | description: "Should reject empty target", |
| 86 | }, |
| 87 | { |
| 88 | name: "whitespace_target", |
| 89 | target: " ", |
| 90 | expectError: true, |
| 91 | description: "Should reject whitespace-only target", |
| 92 | }, |
| 93 | { |
| 94 | name: "complex_package_name", |
| 95 | target: "opencv_contrib@4.11.0", |
| 96 | expectError: false, |
| 97 | description: "Should accept complex package names", |
| 98 | }, |
| 99 | } |
| 100 | |
| 101 | for _, test := range tests { |
| 102 | t.Run(test.name, func(t *testing.T) { |
| 103 | err := treeCmd.validateTarget(test.target) |
| 104 | if test.expectError && err == nil { |
| 105 | t.Errorf("Expected error for %s, got nil", test.description) |
| 106 | } |
| 107 | if !test.expectError && err != nil { |
| 108 | t.Errorf("Expected no error for %s, got: %v", test.description, err) |
| 109 | } |
| 110 | }) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestTreeCmd_Completion(t *testing.T) { |
nothing calls this directly
no test coverage detected