(t *testing.T)
| 185 | } |
| 186 | |
| 187 | func TestRemoveCmd_ValidatePackageNames(t *testing.T) { |
| 188 | // Cleanup. |
| 189 | dirs.RemoveAllForTest() |
| 190 | |
| 191 | remove := &removeCmd{} |
| 192 | |
| 193 | tests := []struct { |
| 194 | name string |
| 195 | packages []string |
| 196 | expectError bool |
| 197 | description string |
| 198 | }{ |
| 199 | { |
| 200 | name: "valid_packages", |
| 201 | packages: []string{"boost@1.87.0", "openssl@3.5.0"}, |
| 202 | expectError: false, |
| 203 | description: "Should accept valid package names", |
| 204 | }, |
| 205 | { |
| 206 | name: "empty_string", |
| 207 | packages: []string{""}, |
| 208 | expectError: true, |
| 209 | description: "Should reject empty package names", |
| 210 | }, |
| 211 | { |
| 212 | name: "whitespace_only", |
| 213 | packages: []string{" "}, |
| 214 | expectError: true, |
| 215 | description: "Should reject whitespace-only package names", |
| 216 | }, |
| 217 | { |
| 218 | name: "missing_version", |
| 219 | packages: []string{"boost"}, |
| 220 | expectError: true, |
| 221 | description: "Should reject package names without version", |
| 222 | }, |
| 223 | { |
| 224 | name: "missing_name", |
| 225 | packages: []string{"@1.87.0"}, |
| 226 | expectError: true, |
| 227 | description: "Should reject version without package name", |
| 228 | }, |
| 229 | { |
| 230 | name: "invalid_format", |
| 231 | packages: []string{"boost-1.87.0"}, |
| 232 | expectError: true, |
| 233 | description: "Should reject packages without @ separator", |
| 234 | }, |
| 235 | { |
| 236 | name: "complex_names", |
| 237 | packages: []string{"opencv_contrib@4.11.0", "my-package@1.0.0-beta"}, |
| 238 | expectError: false, |
| 239 | description: "Should accept complex valid package names", |
| 240 | }, |
| 241 | { |
| 242 | name: "mixed_valid_invalid", |
| 243 | packages: []string{"boost@1.87.0", "invalid-package"}, |
| 244 | expectError: true, |
nothing calls this directly
no test coverage detected