MCPcopy Create free account
hub / github.com/devspace-sh/devspace / TestLessThanOrEqual

Function TestLessThanOrEqual

pkg/util/constraint/version_test.go:611–656  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

609}
610
611func TestLessThanOrEqual(t *testing.T) {
612 cases := []struct {
613 v1 string
614 v2 string
615 expected bool
616 }{
617 {"1.2.3", "1.4.5", true},
618 {"1.2-beta", "1.2-beta", true},
619 {"1.2", "1.1.4", false},
620 {"1.2", "1.2-beta", false},
621 {"1.2+foo", "1.2+beta", true},
622 {"v1.2", "v1.2-beta", false},
623 {"v1.2+foo", "v1.2+beta", true},
624 {"v1.2.3.4", "v1.2.3.4", true},
625 {"v1.2.0.0", "v1.2", true},
626 {"v1.2.0.0.1", "v1.2", false},
627 {"v1.2", "v1.2.0.0", true},
628 {"v1.2", "v1.2.0.0.1", true},
629 {"v1.2.0.0", "v1.2.0.0.1", true},
630 {"v1.2.3.0", "v1.2.3.4", true},
631 {"1.7rc2", "1.7rc1", false},
632 {"1.7rc2", "1.7", true},
633 {"1.2.0", "1.2.0-X-1.2.0+metadata~dist", false},
634 }
635
636 for _, tc := range cases {
637 v1, err := NewVersion(tc.v1)
638 if err != nil {
639 t.Fatalf("err: %s", err)
640 }
641
642 v2, err := NewVersion(tc.v2)
643 if err != nil {
644 t.Fatalf("err: %s", err)
645 }
646
647 actual := v1.LessThanOrEqual(v2)
648 expected := tc.expected
649 if actual != expected {
650 t.Fatalf(
651 "%s <= %s\nexpected: %t\nactual: %t",
652 tc.v1, tc.v2,
653 expected, actual)
654 }
655 }
656}

Callers

nothing calls this directly

Calls 3

LessThanOrEqualMethod · 0.95
NewVersionFunction · 0.85
FatalfMethod · 0.45

Tested by

no test coverage detected