Skip to content

Commit

Permalink
tests: Added tests for the use-cases in Masterminds#150.
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzyx committed Oct 27, 2023
1 parent 2f39fdc commit 43b83a9
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions constraints_test.go
Expand Up @@ -209,6 +209,54 @@ func TestConstraintCheck(t *testing.T) {
}
}

func TestReleaseVsPrerelease(t *testing.T) {
tests := []struct {
constraint string
version string
check bool
}{
{"<1.0.0", "1.0.0-alpha", true},
{"<1.0.0", "1.0.0-beta1", true},
{"<1.0.0", "1.0.0-rc.1", true},
{"<1.0.0", "1.0.0-rc1", true},
{"<2.0.0-0", "1.0.0-alpha", true},
{"<2.0.0-0", "1.0.0-beta1", true},
{"<2.0.0-0", "1.0.0-rc.1", true},
{"<2.0.0-0", "1.0.0-rc1", true},
{"<2.0.0-rc.1", "1.0.0-alpha", true},
{"<2.0.0-rc.1", "1.0.0-beta1", true},
{"<2.0.0-rc.1", "1.0.0-rc.1", true},
{"<2.0.0-rc.1", "1.0.0-rc1", true},
{"<2.0.0", "1.0.0-alpha", true},
{"<2.0.0", "1.0.0-beta1", true},
{"<2.0.0", "1.0.0-rc.1", true},
{"<2.0.0", "1.0.0-rc", true},
{"<2.0.0", "1.0.0-rc1", true},
{"<2.0.0", "1.0.0", true},
{"<2.0", "1.0", true},
{"<2", "1", true},
}

for _, tc := range tests {
c, err := parseConstraint(tc.constraint)
if err != nil {
t.Errorf("err: %s", err)
continue
}

v, err := NewVersion(tc.version)
if err != nil {
t.Errorf("err: %s", err)
continue
}

a, _ := c.check(v)
if a != tc.check {
t.Errorf("Constraint %q failing with %q", tc.constraint, tc.version)
}
}
}

func TestNewConstraint(t *testing.T) {
tests := []struct {
input string
Expand Down

0 comments on commit 43b83a9

Please sign in to comment.