(t *testing.T)
| 422 | } |
| 423 | |
| 424 | func TestReferenceRegexp(t *testing.T) { |
| 425 | if ReferenceRegexp.NumSubexp() != 3 { |
| 426 | t.Fatalf("anchored name regexp should have three submatches: %v, %v != 3", |
| 427 | ReferenceRegexp, ReferenceRegexp.NumSubexp()) |
| 428 | } |
| 429 | |
| 430 | testcases := []regexpMatch{ |
| 431 | { |
| 432 | input: "registry.com:8080/myapp:tag", |
| 433 | match: true, |
| 434 | subs: []string{"registry.com:8080/myapp", "tag", ""}, |
| 435 | }, |
| 436 | { |
| 437 | input: "registry.com:8080/myapp@sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912", |
| 438 | match: true, |
| 439 | subs: []string{"registry.com:8080/myapp", "", "sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912"}, |
| 440 | }, |
| 441 | { |
| 442 | input: "registry.com:8080/myapp:tag2@sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912", |
| 443 | match: true, |
| 444 | subs: []string{"registry.com:8080/myapp", "tag2", "sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912"}, |
| 445 | }, |
| 446 | { |
| 447 | input: "registry.com:8080/myapp@sha256:badbadbadbad", |
| 448 | match: false, |
| 449 | }, |
| 450 | { |
| 451 | input: "registry.com:8080/myapp:invalid~tag", |
| 452 | match: false, |
| 453 | }, |
| 454 | { |
| 455 | input: "bad_hostname.com:8080/myapp:tag", |
| 456 | match: false, |
| 457 | }, |
| 458 | { |
| 459 | input:// localhost treated as name, missing tag with 8080 as tag |
| 460 | "localhost:8080@sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912", |
| 461 | match: true, |
| 462 | subs: []string{"localhost", "8080", "sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912"}, |
| 463 | }, |
| 464 | { |
| 465 | input: "localhost:8080/name@sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912", |
| 466 | match: true, |
| 467 | subs: []string{"localhost:8080/name", "", "sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912"}, |
| 468 | }, |
| 469 | { |
| 470 | input: "localhost:http/name@sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912", |
| 471 | match: false, |
| 472 | }, |
| 473 | { |
| 474 | // localhost will be treated as an image name without a host |
| 475 | input: "localhost@sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912", |
| 476 | match: true, |
| 477 | subs: []string{"localhost", "", "sha256:be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912"}, |
| 478 | }, |
| 479 | { |
| 480 | input: "registry.com:8080/myapp@bad", |
| 481 | match: false, |
nothing calls this directly
no test coverage detected
searching dependent graphs…