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

Function TestConstraintCheck

pkg/util/constraint/constraint_test.go:40–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestConstraintCheck(t *testing.T) {
41 cases := []struct {
42 constraint string
43 version string
44 check bool
45 }{
46 {">= 1.0, < 1.2", "1.1.5", true},
47 {"< 1.0, < 1.2", "1.1.5", false},
48 {"= 1.0", "1.1.5", false},
49 {"= 1.0", "1.0.0", true},
50 {"1.0", "1.0.0", true},
51 {"~> 1.0", "2.0", false},
52 {"~> 1.0", "1.1", true},
53 {"~> 1.0", "1.2.3", true},
54 {"~> 1.0.0", "1.2.3", false},
55 {"~> 1.0.0", "1.0.7", true},
56 {"~> 1.0.0", "1.1.0", false},
57 {"~> 1.0.7", "1.0.4", false},
58 {"~> 1.0.7", "1.0.7", true},
59 {"~> 1.0.7", "1.0.8", true},
60 {"~> 1.0.7", "1.0.7.5", true},
61 {"~> 1.0.7", "1.0.6.99", false},
62 {"~> 1.0.7", "1.0.8.0", true},
63 {"~> 1.0.9.5", "1.0.9.5", true},
64 {"~> 1.0.9.5", "1.0.9.4", false},
65 {"~> 1.0.9.5", "1.0.9.6", true},
66 {"~> 1.0.9.5", "1.0.9.5.0", true},
67 {"~> 1.0.9.5", "1.0.9.5.1", true},
68 {"~> 2.0", "2.1.0-beta", true},
69 {"~> 2.1.0-a", "2.2.0", false},
70 {"~> 2.1.0-a", "2.1.0", false},
71 {"~> 2.1.0-a", "2.1.0-beta", true},
72 {"~> 2.1.0-a", "2.2.0-alpha", false},
73 {"> 2.0", "2.1.0-beta", true},
74 {">= 2.1.0-a", "2.1.0-beta", true},
75 {">= 2.1.0-a", "2.1.1-beta", true},
76 {">= 2.0.0", "2.1.0-beta", true},
77 {">= 2.0.0-beta.0", "2.0.0-beta.2", true},
78 {">= 2.0.0-beta.0", "2.0.1-beta.0", true},
79 {">= 2.0.1-beta.0", "2.0.0-beta.0", false},
80 {">= 2.1.0-a", "2.1.1", true},
81 {">= 2.1.0-a", "2.1.0", true},
82 {"<= 2.1.0-a", "2.0.0", true},
83 }
84
85 for _, tc := range cases {
86 c, err := NewConstraint(tc.constraint)
87 if err != nil {
88 t.Fatalf("err: %s", err)
89 }
90
91 v, err := NewVersion(tc.version)
92 if err != nil {
93 t.Fatalf("err: %s", err)
94 }
95
96 actual := c.Check(v)
97 expected := tc.check

Callers

nothing calls this directly

Calls 4

CheckMethod · 0.95
NewConstraintFunction · 0.85
NewVersionFunction · 0.85
FatalfMethod · 0.45

Tested by

no test coverage detected