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

Function TestLessThan

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

Source from the content-addressed store, hash-verified

515}
516
517func TestLessThan(t *testing.T) {
518 cases := []struct {
519 v1 string
520 v2 string
521 expected bool
522 }{
523 {"1.2.3", "1.4.5", true},
524 {"1.2-beta", "1.2-beta", false},
525 {"1.2", "1.1.4", false},
526 {"1.2", "1.2-beta", false},
527 {"1.2+foo", "1.2+beta", false},
528 {"v1.2", "v1.2-beta", false},
529 {"v1.2+foo", "v1.2+beta", false},
530 {"v1.2.3.4", "v1.2.3.4", false},
531 {"v1.2.0.0", "v1.2", false},
532 {"v1.2.0.0.1", "v1.2", false},
533 {"v1.2", "v1.2.0.0", false},
534 {"v1.2", "v1.2.0.0.1", true},
535 {"v1.2.0.0", "v1.2.0.0.1", true},
536 {"v1.2.3.0", "v1.2.3.4", true},
537 {"1.7rc2", "1.7rc1", false},
538 {"1.7rc2", "1.7", true},
539 {"1.2.0", "1.2.0-X-1.2.0+metadata~dist", false},
540 }
541
542 for _, tc := range cases {
543 v1, err := NewVersion(tc.v1)
544 if err != nil {
545 t.Fatalf("err: %s", err)
546 }
547
548 v2, err := NewVersion(tc.v2)
549 if err != nil {
550 t.Fatalf("err: %s", err)
551 }
552
553 actual := v1.LessThan(v2)
554 expected := tc.expected
555 if actual != expected {
556 t.Fatalf(
557 "%s < %s\nexpected: %t\nactual: %t",
558 tc.v1, tc.v2,
559 expected, actual)
560 }
561 }
562}
563
564func TestGreaterThanOrEqual(t *testing.T) {
565 cases := []struct {

Callers

nothing calls this directly

Calls 3

LessThanMethod · 0.95
NewVersionFunction · 0.85
FatalfMethod · 0.45

Tested by

no test coverage detected