MCPcopy Create free account
hub / github.com/containers/image / TestMatch

Function TestMatch

docker/reference/normalize_test.go:507–572  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

505}
506
507func TestMatch(t *testing.T) {
508 matchCases := []struct {
509 reference string
510 pattern string
511 expected bool
512 }{
513 {
514 reference: "foo",
515 pattern: "foo/**/ba[rz]",
516 expected: false,
517 },
518 {
519 reference: "foo/any/bat",
520 pattern: "foo/**/ba[rz]",
521 expected: false,
522 },
523 {
524 reference: "foo/a/bar",
525 pattern: "foo/**/ba[rz]",
526 expected: true,
527 },
528 {
529 reference: "foo/b/baz",
530 pattern: "foo/**/ba[rz]",
531 expected: true,
532 },
533 {
534 reference: "foo/c/baz:tag",
535 pattern: "foo/**/ba[rz]",
536 expected: true,
537 },
538 {
539 reference: "foo/c/baz:tag",
540 pattern: "foo/*/baz:tag",
541 expected: true,
542 },
543 {
544 reference: "foo/c/baz:tag",
545 pattern: "foo/c/baz:tag",
546 expected: true,
547 },
548 {
549 reference: "example.com/foo/c/baz:tag",
550 pattern: "*/foo/c/baz",
551 expected: true,
552 },
553 {
554 reference: "example.com/foo/c/baz:tag",
555 pattern: "example.com/foo/c/baz",
556 expected: true,
557 },
558 }
559 for _, c := range matchCases {
560 named, err := ParseAnyReference(c.reference)
561 if err != nil {
562 t.Fatal(err)
563 }
564 actual, err := FamiliarMatch(c.pattern, named)

Callers

nothing calls this directly

Calls 2

ParseAnyReferenceFunction · 0.85
FamiliarMatchFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…