| 238 | } |
| 239 | |
| 240 | func TestAlphaNumericDashUnderscoreRegex(t *testing.T) { |
| 241 | testcases := []regexpMatch{ |
| 242 | { |
| 243 | input: "generic.package.com", |
| 244 | match: false, |
| 245 | }, |
| 246 | { |
| 247 | input: "generic_package.com", |
| 248 | match: false, |
| 249 | }, |
| 250 | { |
| 251 | input: "_value-123", |
| 252 | match: true, |
| 253 | }, |
| 254 | { |
| 255 | input: "data.generic.package()", |
| 256 | match: false, |
| 257 | }, |
| 258 | { |
| 259 | input: "!variable", |
| 260 | match: false, |
| 261 | }, |
| 262 | { |
| 263 | input: "assignment=value", |
| 264 | match: false, |
| 265 | }, |
| 266 | { |
| 267 | input: "LibrayPackage@model.net", |
| 268 | match: false, |
| 269 | }, |
| 270 | { |
| 271 | input: "aaaabbbbcccABCDZX-123456789", |
| 272 | match: true, |
| 273 | }, |
| 274 | { |
| 275 | input: "word1-word2_word3_word4", |
| 276 | match: true, |
| 277 | }, |
| 278 | { |
| 279 | input: "____-----____", |
| 280 | match: true, |
| 281 | }, |
| 282 | { |
| 283 | input: "(word)", |
| 284 | match: false, |
| 285 | }, |
| 286 | } |
| 287 | |
| 288 | for i := range testcases { |
| 289 | match := _alphaNumericDashUnderscoreRegex.MatchString(testcases[i].input) |
| 290 | if match != testcases[i].match { |
| 291 | t.Errorf("No match for %q", testcases[i].input) |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | func TestValidDockerImage(t *testing.T) { |
| 297 | testcases := []regexpMatch{ |