Switch from glide to govendor
This commit is contained in:
25
vendor/github.com/Masterminds/semver/.travis.yml
generated
vendored
25
vendor/github.com/Masterminds/semver/.travis.yml
generated
vendored
@@ -1,25 +0,0 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.5
|
||||
- 1.6
|
||||
- 1.7
|
||||
- tip
|
||||
|
||||
# Setting sudo access to false will let Travis CI use containers rather than
|
||||
# VMs to run the tests. For more details see:
|
||||
# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
# - http://docs.travis-ci.com/user/workers/standard-infrastructure/
|
||||
sudo: false
|
||||
|
||||
script:
|
||||
- GO15VENDOREXPERIMENT=1 make setup
|
||||
- GO15VENDOREXPERIMENT=1 make test
|
||||
|
||||
notifications:
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/06e3328629952dabe3e0
|
||||
on_success: change # options: [always|never|change] default: always
|
||||
on_failure: always # options: [always|never|change] default: always
|
||||
on_start: never # options: [always|never|change] default: always
|
157
vendor/github.com/Masterminds/semver/benchmark_test.go
generated
vendored
157
vendor/github.com/Masterminds/semver/benchmark_test.go
generated
vendored
@@ -1,157 +0,0 @@
|
||||
package semver_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
)
|
||||
|
||||
/* Constraint creation benchmarks */
|
||||
|
||||
func benchNewConstraint(c string, b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
semver.NewConstraint(c)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNewConstraintUnary(b *testing.B) {
|
||||
benchNewConstraint("=2.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewConstraintTilde(b *testing.B) {
|
||||
benchNewConstraint("~2.0.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewConstraintCaret(b *testing.B) {
|
||||
benchNewConstraint("^2.0.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewConstraintWildcard(b *testing.B) {
|
||||
benchNewConstraint("1.x", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewConstraintRange(b *testing.B) {
|
||||
benchNewConstraint(">=2.1.x, <3.1.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewConstraintUnion(b *testing.B) {
|
||||
benchNewConstraint("~2.0.0 || =3.1.0", b)
|
||||
}
|
||||
|
||||
/* Check benchmarks */
|
||||
|
||||
func benchCheckVersion(c, v string, b *testing.B) {
|
||||
version, _ := semver.NewVersion(v)
|
||||
constraint, _ := semver.NewConstraint(c)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
constraint.Check(version)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCheckVersionUnary(b *testing.B) {
|
||||
benchCheckVersion("=2.0", "2.0.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkCheckVersionTilde(b *testing.B) {
|
||||
benchCheckVersion("~2.0.0", "2.0.5", b)
|
||||
}
|
||||
|
||||
func BenchmarkCheckVersionCaret(b *testing.B) {
|
||||
benchCheckVersion("^2.0.0", "2.1.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkCheckVersionWildcard(b *testing.B) {
|
||||
benchCheckVersion("1.x", "1.4.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkCheckVersionRange(b *testing.B) {
|
||||
benchCheckVersion(">=2.1.x, <3.1.0", "2.4.5", b)
|
||||
}
|
||||
|
||||
func BenchmarkCheckVersionUnion(b *testing.B) {
|
||||
benchCheckVersion("~2.0.0 || =3.1.0", "3.1.0", b)
|
||||
}
|
||||
|
||||
func benchValidateVersion(c, v string, b *testing.B) {
|
||||
version, _ := semver.NewVersion(v)
|
||||
constraint, _ := semver.NewConstraint(c)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
constraint.Validate(version)
|
||||
}
|
||||
}
|
||||
|
||||
/* Validate benchmarks, including fails */
|
||||
|
||||
func BenchmarkValidateVersionUnary(b *testing.B) {
|
||||
benchValidateVersion("=2.0", "2.0.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionUnaryFail(b *testing.B) {
|
||||
benchValidateVersion("=2.0", "2.0.1", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionTilde(b *testing.B) {
|
||||
benchValidateVersion("~2.0.0", "2.0.5", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionTildeFail(b *testing.B) {
|
||||
benchValidateVersion("~2.0.0", "1.0.5", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionCaret(b *testing.B) {
|
||||
benchValidateVersion("^2.0.0", "2.1.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionCaretFail(b *testing.B) {
|
||||
benchValidateVersion("^2.0.0", "4.1.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionWildcard(b *testing.B) {
|
||||
benchValidateVersion("1.x", "1.4.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionWildcardFail(b *testing.B) {
|
||||
benchValidateVersion("1.x", "2.4.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionRange(b *testing.B) {
|
||||
benchValidateVersion(">=2.1.x, <3.1.0", "2.4.5", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionRangeFail(b *testing.B) {
|
||||
benchValidateVersion(">=2.1.x, <3.1.0", "1.4.5", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionUnion(b *testing.B) {
|
||||
benchValidateVersion("~2.0.0 || =3.1.0", "3.1.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkValidateVersionUnionFail(b *testing.B) {
|
||||
benchValidateVersion("~2.0.0 || =3.1.0", "3.1.1", b)
|
||||
}
|
||||
|
||||
/* Version creation benchmarks */
|
||||
|
||||
func benchNewVersion(v string, b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
semver.NewVersion(v)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNewVersionSimple(b *testing.B) {
|
||||
benchNewVersion("1.0.0", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewVersionPre(b *testing.B) {
|
||||
benchNewVersion("1.0.0-alpha", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewVersionMeta(b *testing.B) {
|
||||
benchNewVersion("1.0.0+metadata", b)
|
||||
}
|
||||
|
||||
func BenchmarkNewVersionMetaDash(b *testing.B) {
|
||||
benchNewVersion("1.0.0+metadata-dash", b)
|
||||
}
|
46
vendor/github.com/Masterminds/semver/collection_test.go
generated
vendored
46
vendor/github.com/Masterminds/semver/collection_test.go
generated
vendored
@@ -1,46 +0,0 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCollection(t *testing.T) {
|
||||
raw := []string{
|
||||
"1.2.3",
|
||||
"1.0",
|
||||
"1.3",
|
||||
"2",
|
||||
"0.4.2",
|
||||
}
|
||||
|
||||
vs := make([]*Version, len(raw))
|
||||
for i, r := range raw {
|
||||
v, err := NewVersion(r)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
vs[i] = v
|
||||
}
|
||||
|
||||
sort.Sort(Collection(vs))
|
||||
|
||||
e := []string{
|
||||
"0.4.2",
|
||||
"1.0.0",
|
||||
"1.2.3",
|
||||
"1.3.0",
|
||||
"2.0.0",
|
||||
}
|
||||
|
||||
a := make([]string, len(vs))
|
||||
for i, v := range vs {
|
||||
a[i] = v.String()
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(a, e) {
|
||||
t.Error("Sorting Collection failed")
|
||||
}
|
||||
}
|
452
vendor/github.com/Masterminds/semver/constraints_test.go
generated
vendored
452
vendor/github.com/Masterminds/semver/constraints_test.go
generated
vendored
@@ -1,452 +0,0 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseConstraint(t *testing.T) {
|
||||
tests := []struct {
|
||||
in string
|
||||
f cfunc
|
||||
v string
|
||||
err bool
|
||||
}{
|
||||
{">= 1.2", constraintGreaterThanEqual, "1.2.0", false},
|
||||
{"1.0", constraintTildeOrEqual, "1.0.0", false},
|
||||
{"foo", nil, "", true},
|
||||
{"<= 1.2", constraintLessThanEqual, "1.2.0", false},
|
||||
{"=< 1.2", constraintLessThanEqual, "1.2.0", false},
|
||||
{"=> 1.2", constraintGreaterThanEqual, "1.2.0", false},
|
||||
{"v1.2", constraintTildeOrEqual, "1.2.0", false},
|
||||
{"=1.5", constraintTildeOrEqual, "1.5.0", false},
|
||||
{"> 1.3", constraintGreaterThan, "1.3.0", false},
|
||||
{"< 1.4.1", constraintLessThan, "1.4.1", false},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
c, err := parseConstraint(tc.in)
|
||||
if tc.err && err == nil {
|
||||
t.Errorf("Expected error for %s didn't occur", tc.in)
|
||||
} else if !tc.err && err != nil {
|
||||
t.Errorf("Unexpected error for %s", tc.in)
|
||||
}
|
||||
|
||||
// If an error was expected continue the loop and don't try the other
|
||||
// tests as they will cause errors.
|
||||
if tc.err {
|
||||
continue
|
||||
}
|
||||
|
||||
if tc.v != c.con.String() {
|
||||
t.Errorf("Incorrect version found on %s", tc.in)
|
||||
}
|
||||
|
||||
f1 := reflect.ValueOf(tc.f)
|
||||
f2 := reflect.ValueOf(c.function)
|
||||
if f1 != f2 {
|
||||
t.Errorf("Wrong constraint found for %s", tc.in)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraintCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
constraint string
|
||||
version string
|
||||
check bool
|
||||
}{
|
||||
{"= 2.0", "1.2.3", false},
|
||||
{"= 2.0", "2.0.0", true},
|
||||
{"4.1", "4.1.0", true},
|
||||
{"!=4.1", "4.1.0", false},
|
||||
{"!=4.1", "5.1.0", true},
|
||||
{">1.1", "4.1.0", true},
|
||||
{">1.1", "1.1.0", false},
|
||||
{"<1.1", "0.1.0", true},
|
||||
{"<1.1", "1.1.0", false},
|
||||
{"<1.1", "1.1.1", false},
|
||||
{">=1.1", "4.1.0", true},
|
||||
{">=1.1", "1.1.0", true},
|
||||
{">=1.1", "0.0.9", false},
|
||||
{"<=1.1", "0.1.0", true},
|
||||
{"<=1.1", "1.1.0", true},
|
||||
{"<=1.1", "1.1.1", false},
|
||||
{">0", "0.0.1-alpha", true},
|
||||
{">=0", "0.0.1-alpha", true},
|
||||
{">0", "0", false},
|
||||
{">=0", "0", 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
|
||||
ors int
|
||||
count int
|
||||
err bool
|
||||
}{
|
||||
{">= 1.1", 1, 1, false},
|
||||
{"2.0", 1, 1, false},
|
||||
{"v2.3.5-20161202202307-sha.e8fc5e5", 1, 1, false},
|
||||
{">= bar", 0, 0, true},
|
||||
{">= 1.2.3, < 2.0", 1, 2, false},
|
||||
{">= 1.2.3, < 2.0 || => 3.0, < 4", 2, 2, false},
|
||||
|
||||
// The 3 - 4 should be broken into 2 by the range rewriting
|
||||
{"3 - 4 || => 3.0, < 4", 2, 2, false},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v, err := NewConstraint(tc.input)
|
||||
if tc.err && err == nil {
|
||||
t.Errorf("expected but did not get error for: %s", tc.input)
|
||||
continue
|
||||
} else if !tc.err && err != nil {
|
||||
t.Errorf("unexpectederror for input %s: %s", tc.input, err)
|
||||
continue
|
||||
}
|
||||
if tc.err {
|
||||
continue
|
||||
}
|
||||
|
||||
l := len(v.constraints)
|
||||
if tc.ors != l {
|
||||
t.Errorf("Expected %s to have %d ORs but got %d",
|
||||
tc.input, tc.ors, l)
|
||||
}
|
||||
|
||||
l = len(v.constraints[0])
|
||||
if tc.count != l {
|
||||
t.Errorf("Expected %s to have %d constraints but got %d",
|
||||
tc.input, tc.count, l)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraintsCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
constraint string
|
||||
version string
|
||||
check bool
|
||||
}{
|
||||
{"*", "1.2.3", true},
|
||||
{"~0.0.0", "1.2.3", true},
|
||||
{"= 2.0", "1.2.3", false},
|
||||
{"= 2.0", "2.0.0", true},
|
||||
{"4.1", "4.1.0", true},
|
||||
{"4.1.x", "4.1.3", true},
|
||||
{"1.x", "1.4", true},
|
||||
{"!=4.1", "4.1.0", false},
|
||||
{"!=4.1-alpha", "4.1.0-alpha", false},
|
||||
{"!=4.1-alpha", "4.1.0", true},
|
||||
{"!=4.1", "5.1.0", true},
|
||||
{"!=4.x", "5.1.0", true},
|
||||
{"!=4.x", "4.1.0", false},
|
||||
{"!=4.1.x", "4.2.0", true},
|
||||
{"!=4.2.x", "4.2.3", false},
|
||||
{">1.1", "4.1.0", true},
|
||||
{">1.1", "1.1.0", false},
|
||||
{"<1.1", "0.1.0", true},
|
||||
{"<1.1", "1.1.0", false},
|
||||
{"<1.1", "1.1.1", false},
|
||||
{"<1.x", "1.1.1", true},
|
||||
{"<1.x", "2.1.1", false},
|
||||
{"<1.1.x", "1.2.1", false},
|
||||
{"<1.1.x", "1.1.500", true},
|
||||
{"<1.2.x", "1.1.1", true},
|
||||
{">=1.1", "4.1.0", true},
|
||||
{">=1.1", "4.1.0-beta", false},
|
||||
{">=1.1", "1.1.0", true},
|
||||
{">=1.1", "0.0.9", false},
|
||||
{"<=1.1", "0.1.0", true},
|
||||
{"<=1.1", "0.1.0-alpha", false},
|
||||
{"<=1.1-a", "0.1.0-alpha", true},
|
||||
{"<=1.1", "1.1.0", true},
|
||||
{"<=1.x", "1.1.0", true},
|
||||
{"<=2.x", "3.1.0", false},
|
||||
{"<=1.1", "1.1.1", false},
|
||||
{"<=1.1.x", "1.2.500", false},
|
||||
{">1.1, <2", "1.1.1", true},
|
||||
{">1.1, <3", "4.3.2", false},
|
||||
{">=1.1, <2, !=1.2.3", "1.2.3", false},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "3.1.2", true},
|
||||
{">=1.1, <2, !=1.2.3 || >= 3", "3.0.0", true},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "3.0.0", false},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "1.2.3", false},
|
||||
{"1.1 - 2", "1.1.1", true},
|
||||
{"1.1-3", "4.3.2", false},
|
||||
{"^1.1", "1.1.1", true},
|
||||
{"^1.1", "4.3.2", false},
|
||||
{"^1.x", "1.1.1", true},
|
||||
{"^2.x", "1.1.1", false},
|
||||
{"^1.x", "2.1.1", false},
|
||||
{"^1.x", "1.1.1-beta1", false},
|
||||
{"^1.1.2-alpha", "1.2.1-beta1", true},
|
||||
{"^1.2.x-alpha", "1.1.1-beta1", false},
|
||||
{"~*", "2.1.1", true},
|
||||
{"~1.x", "2.1.1", false},
|
||||
{"~1.x", "1.3.5", true},
|
||||
{"~1.x", "1.4", true},
|
||||
{"~1.1", "1.1.1", true},
|
||||
{"~1.1", "1.1.1-alpha", false},
|
||||
{"~1.1-alpha", "1.1.1-beta", true},
|
||||
{"~1.1.1-beta", "1.1.1-alpha", false},
|
||||
{"~1.1.1-beta", "1.1.1", true},
|
||||
{"~1.2.3", "1.2.5", true},
|
||||
{"~1.2.3", "1.2.2", false},
|
||||
{"~1.2.3", "1.3.2", false},
|
||||
{"~1.1", "1.2.3", false},
|
||||
{"~1.3", "2.4.5", false},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
c, err := NewConstraint(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 '%s' failing with '%s'", tc.constraint, tc.version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteRange(t *testing.T) {
|
||||
tests := []struct {
|
||||
c string
|
||||
nc string
|
||||
}{
|
||||
{"2 - 3", ">= 2, <= 3"},
|
||||
{"2 - 3, 2 - 3", ">= 2, <= 3,>= 2, <= 3"},
|
||||
{"2 - 3, 4.0.0 - 5.1", ">= 2, <= 3,>= 4.0.0, <= 5.1"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
o := rewriteRange(tc.c)
|
||||
|
||||
if o != tc.nc {
|
||||
t.Errorf("Range %s rewritten incorrectly as '%s'", tc.c, o)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsX(t *testing.T) {
|
||||
tests := []struct {
|
||||
t string
|
||||
c bool
|
||||
}{
|
||||
{"A", false},
|
||||
{"%", false},
|
||||
{"X", true},
|
||||
{"x", true},
|
||||
{"*", true},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
a := isX(tc.t)
|
||||
if a != tc.c {
|
||||
t.Errorf("Function isX error on %s", tc.t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraintsValidate(t *testing.T) {
|
||||
tests := []struct {
|
||||
constraint string
|
||||
version string
|
||||
check bool
|
||||
}{
|
||||
{"*", "1.2.3", true},
|
||||
{"~0.0.0", "1.2.3", true},
|
||||
{"= 2.0", "1.2.3", false},
|
||||
{"= 2.0", "2.0.0", true},
|
||||
{"4.1", "4.1.0", true},
|
||||
{"4.1.x", "4.1.3", true},
|
||||
{"1.x", "1.4", true},
|
||||
{"!=4.1", "4.1.0", false},
|
||||
{"!=4.1", "5.1.0", true},
|
||||
{"!=4.x", "5.1.0", true},
|
||||
{"!=4.x", "4.1.0", false},
|
||||
{"!=4.1.x", "4.2.0", true},
|
||||
{"!=4.2.x", "4.2.3", false},
|
||||
{">1.1", "4.1.0", true},
|
||||
{">1.1", "1.1.0", false},
|
||||
{"<1.1", "0.1.0", true},
|
||||
{"<1.1", "1.1.0", false},
|
||||
{"<1.1", "1.1.1", false},
|
||||
{"<1.x", "1.1.1", true},
|
||||
{"<1.x", "2.1.1", false},
|
||||
{"<1.1.x", "1.2.1", false},
|
||||
{"<1.1.x", "1.1.500", true},
|
||||
{"<1.2.x", "1.1.1", true},
|
||||
{">=1.1", "4.1.0", true},
|
||||
{">=1.1", "1.1.0", true},
|
||||
{">=1.1", "0.0.9", false},
|
||||
{"<=1.1", "0.1.0", true},
|
||||
{"<=1.1", "1.1.0", true},
|
||||
{"<=1.x", "1.1.0", true},
|
||||
{"<=2.x", "3.1.0", false},
|
||||
{"<=1.1", "1.1.1", false},
|
||||
{"<=1.1.x", "1.2.500", false},
|
||||
{">1.1, <2", "1.1.1", true},
|
||||
{">1.1, <3", "4.3.2", false},
|
||||
{">=1.1, <2, !=1.2.3", "1.2.3", false},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "3.1.2", true},
|
||||
{">=1.1, <2, !=1.2.3 || >= 3", "3.0.0", true},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "3.0.0", false},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "1.2.3", false},
|
||||
{"1.1 - 2", "1.1.1", true},
|
||||
{"1.1-3", "4.3.2", false},
|
||||
{"^1.1", "1.1.1", true},
|
||||
{"^1.1", "1.1.1-alpha", false},
|
||||
{"^1.1.1-alpha", "1.1.1-beta", true},
|
||||
{"^1.1.1-beta", "1.1.1-alpha", false},
|
||||
{"^1.1", "4.3.2", false},
|
||||
{"^1.x", "1.1.1", true},
|
||||
{"^2.x", "1.1.1", false},
|
||||
{"^1.x", "2.1.1", false},
|
||||
{"~*", "2.1.1", true},
|
||||
{"~1.x", "2.1.1", false},
|
||||
{"~1.x", "1.3.5", true},
|
||||
{"~1.x", "1.3.5-beta", false},
|
||||
{"~1.3.6-alpha", "1.3.5-beta", false},
|
||||
{"~1.3.5-alpha", "1.3.5-beta", true},
|
||||
{"~1.3.5-beta", "1.3.5-alpha", false},
|
||||
{"~1.x", "1.4", true},
|
||||
{"~1.1", "1.1.1", true},
|
||||
{"~1.2.3", "1.2.5", true},
|
||||
{"~1.2.3", "1.2.2", false},
|
||||
{"~1.2.3", "1.3.2", false},
|
||||
{"~1.1", "1.2.3", false},
|
||||
{"~1.3", "2.4.5", false},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
c, err := NewConstraint(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, msgs := c.Validate(v)
|
||||
if a != tc.check {
|
||||
t.Errorf("Constraint '%s' failing with '%s'", tc.constraint, tc.version)
|
||||
} else if !a && len(msgs) == 0 {
|
||||
t.Errorf("%q failed with %q but no errors returned", tc.constraint, tc.version)
|
||||
}
|
||||
|
||||
// if a == false {
|
||||
// for _, m := range msgs {
|
||||
// t.Errorf("%s", m)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
v, err := NewVersion("1.2.3")
|
||||
if err != nil {
|
||||
t.Errorf("err: %s", err)
|
||||
}
|
||||
|
||||
c, err := NewConstraint("!= 1.2.5, ^2, <= 1.1.x")
|
||||
if err != nil {
|
||||
t.Errorf("err: %s", err)
|
||||
}
|
||||
|
||||
_, msgs := c.Validate(v)
|
||||
if len(msgs) != 2 {
|
||||
t.Error("Invalid number of validations found")
|
||||
}
|
||||
e := msgs[0].Error()
|
||||
if e != "1.2.3 does not have same major version as 2" {
|
||||
t.Error("Did not get expected message: 1.2.3 does not have same major version as 2")
|
||||
}
|
||||
e = msgs[1].Error()
|
||||
if e != "1.2.3 is greater than 1.1.x" {
|
||||
t.Error("Did not get expected message: 1.2.3 is greater than 1.1.x")
|
||||
}
|
||||
|
||||
tests2 := []struct {
|
||||
constraint, version, msg string
|
||||
}{
|
||||
{"= 2.0", "1.2.3", "1.2.3 is not equal to 2.0"},
|
||||
{"!=4.1", "4.1.0", "4.1.0 is equal to 4.1"},
|
||||
{"!=4.x", "4.1.0", "4.1.0 is equal to 4.x"},
|
||||
{"!=4.2.x", "4.2.3", "4.2.3 is equal to 4.2.x"},
|
||||
{">1.1", "1.1.0", "1.1.0 is less than or equal to 1.1"},
|
||||
{"<1.1", "1.1.0", "1.1.0 is greater than or equal to 1.1"},
|
||||
{"<1.1", "1.1.1", "1.1.1 is greater than or equal to 1.1"},
|
||||
{"<1.x", "2.1.1", "2.1.1 is greater than or equal to 1.x"},
|
||||
{"<1.1.x", "1.2.1", "1.2.1 is greater than or equal to 1.1.x"},
|
||||
{">=1.1", "0.0.9", "0.0.9 is less than 1.1"},
|
||||
{"<=2.x", "3.1.0", "3.1.0 is greater than 2.x"},
|
||||
{"<=1.1", "1.1.1", "1.1.1 is greater than 1.1"},
|
||||
{"<=1.1.x", "1.2.500", "1.2.500 is greater than 1.1.x"},
|
||||
{">1.1, <3", "4.3.2", "4.3.2 is greater than or equal to 3"},
|
||||
{">=1.1, <2, !=1.2.3", "1.2.3", "1.2.3 is equal to 1.2.3"},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "3.0.0", "3.0.0 is greater than or equal to 2"},
|
||||
{">=1.1, <2, !=1.2.3 || > 3", "1.2.3", "1.2.3 is equal to 1.2.3"},
|
||||
{"1.1 - 3", "4.3.2", "4.3.2 is greater than 3"},
|
||||
{"^1.1", "4.3.2", "4.3.2 does not have same major version as 1.1"},
|
||||
{"^2.x", "1.1.1", "1.1.1 does not have same major version as 2.x"},
|
||||
{"^1.x", "2.1.1", "2.1.1 does not have same major version as 1.x"},
|
||||
{"~1.x", "2.1.1", "2.1.1 does not have same major and minor version as 1.x"},
|
||||
{"~1.2.3", "1.2.2", "1.2.2 does not have same major and minor version as 1.2.3"},
|
||||
{"~1.2.3", "1.3.2", "1.3.2 does not have same major and minor version as 1.2.3"},
|
||||
{"~1.1", "1.2.3", "1.2.3 does not have same major and minor version as 1.1"},
|
||||
{"~1.3", "2.4.5", "2.4.5 does not have same major and minor version as 1.3"},
|
||||
}
|
||||
|
||||
for _, tc := range tests2 {
|
||||
c, err := NewConstraint(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
|
||||
}
|
||||
|
||||
_, msgs := c.Validate(v)
|
||||
e := msgs[0].Error()
|
||||
if e != tc.msg {
|
||||
t.Errorf("Did not get expected message %q: %s", tc.msg, e)
|
||||
}
|
||||
}
|
||||
}
|
450
vendor/github.com/Masterminds/semver/version_test.go
generated
vendored
450
vendor/github.com/Masterminds/semver/version_test.go
generated
vendored
@@ -1,450 +0,0 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewVersion(t *testing.T) {
|
||||
tests := []struct {
|
||||
version string
|
||||
err bool
|
||||
}{
|
||||
{"1.2.3", false},
|
||||
{"v1.2.3", false},
|
||||
{"1.0", false},
|
||||
{"v1.0", false},
|
||||
{"1", false},
|
||||
{"v1", false},
|
||||
{"1.2.beta", true},
|
||||
{"v1.2.beta", true},
|
||||
{"foo", true},
|
||||
{"1.2-5", false},
|
||||
{"v1.2-5", false},
|
||||
{"1.2-beta.5", false},
|
||||
{"v1.2-beta.5", false},
|
||||
{"\n1.2", true},
|
||||
{"\nv1.2", true},
|
||||
{"1.2.0-x.Y.0+metadata", false},
|
||||
{"v1.2.0-x.Y.0+metadata", false},
|
||||
{"1.2.0-x.Y.0+metadata-width-hypen", false},
|
||||
{"v1.2.0-x.Y.0+metadata-width-hypen", false},
|
||||
{"1.2.3-rc1-with-hypen", false},
|
||||
{"v1.2.3-rc1-with-hypen", false},
|
||||
{"1.2.3.4", true},
|
||||
{"v1.2.3.4", true},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
_, err := NewVersion(tc.version)
|
||||
if tc.err && err == nil {
|
||||
t.Fatalf("expected error for version: %s", tc.version)
|
||||
} else if !tc.err && err != nil {
|
||||
t.Fatalf("error for version %s: %s", tc.version, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOriginal(t *testing.T) {
|
||||
tests := []string{
|
||||
"1.2.3",
|
||||
"v1.2.3",
|
||||
"1.0",
|
||||
"v1.0",
|
||||
"1",
|
||||
"v1",
|
||||
"1.2-5",
|
||||
"v1.2-5",
|
||||
"1.2-beta.5",
|
||||
"v1.2-beta.5",
|
||||
"1.2.0-x.Y.0+metadata",
|
||||
"v1.2.0-x.Y.0+metadata",
|
||||
"1.2.0-x.Y.0+metadata-width-hypen",
|
||||
"v1.2.0-x.Y.0+metadata-width-hypen",
|
||||
"1.2.3-rc1-with-hypen",
|
||||
"v1.2.3-rc1-with-hypen",
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v, err := NewVersion(tc)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version %s", tc)
|
||||
}
|
||||
|
||||
o := v.Original()
|
||||
if o != tc {
|
||||
t.Errorf("Error retrieving originl. Expected '%s' but got '%s'", tc, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParts(t *testing.T) {
|
||||
v, err := NewVersion("1.2.3-beta.1+build.123")
|
||||
if err != nil {
|
||||
t.Error("Error parsing version 1.2.3-beta.1+build.123")
|
||||
}
|
||||
|
||||
if v.Major() != 1 {
|
||||
t.Error("Major() returning wrong value")
|
||||
}
|
||||
if v.Minor() != 2 {
|
||||
t.Error("Minor() returning wrong value")
|
||||
}
|
||||
if v.Patch() != 3 {
|
||||
t.Error("Patch() returning wrong value")
|
||||
}
|
||||
if v.Prerelease() != "beta.1" {
|
||||
t.Error("Prerelease() returning wrong value")
|
||||
}
|
||||
if v.Metadata() != "build.123" {
|
||||
t.Error("Metadata() returning wrong value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
tests := []struct {
|
||||
version string
|
||||
expected string
|
||||
}{
|
||||
{"1.2.3", "1.2.3"},
|
||||
{"v1.2.3", "1.2.3"},
|
||||
{"1.0", "1.0.0"},
|
||||
{"v1.0", "1.0.0"},
|
||||
{"1", "1.0.0"},
|
||||
{"v1", "1.0.0"},
|
||||
{"1.2-5", "1.2.0-5"},
|
||||
{"v1.2-5", "1.2.0-5"},
|
||||
{"1.2-beta.5", "1.2.0-beta.5"},
|
||||
{"v1.2-beta.5", "1.2.0-beta.5"},
|
||||
{"1.2.0-x.Y.0+metadata", "1.2.0-x.Y.0+metadata"},
|
||||
{"v1.2.0-x.Y.0+metadata", "1.2.0-x.Y.0+metadata"},
|
||||
{"1.2.0-x.Y.0+metadata-width-hypen", "1.2.0-x.Y.0+metadata-width-hypen"},
|
||||
{"v1.2.0-x.Y.0+metadata-width-hypen", "1.2.0-x.Y.0+metadata-width-hypen"},
|
||||
{"1.2.3-rc1-with-hypen", "1.2.3-rc1-with-hypen"},
|
||||
{"v1.2.3-rc1-with-hypen", "1.2.3-rc1-with-hypen"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v, err := NewVersion(tc.version)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version %s", tc)
|
||||
}
|
||||
|
||||
s := v.String()
|
||||
if s != tc.expected {
|
||||
t.Errorf("Error generating string. Expected '%s' but got '%s'", tc.expected, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompare(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
v2 string
|
||||
expected int
|
||||
}{
|
||||
{"1.2.3", "1.5.1", -1},
|
||||
{"2.2.3", "1.5.1", 1},
|
||||
{"2.2.3", "2.2.2", 1},
|
||||
{"3.2-beta", "3.2-beta", 0},
|
||||
{"1.3", "1.1.4", 1},
|
||||
{"4.2", "4.2-beta", 1},
|
||||
{"4.2-beta", "4.2", -1},
|
||||
{"4.2-alpha", "4.2-beta", -1},
|
||||
{"4.2-alpha", "4.2-alpha", 0},
|
||||
{"4.2-beta.2", "4.2-beta.1", 1},
|
||||
{"4.2-beta2", "4.2-beta1", 1},
|
||||
{"4.2-beta", "4.2-beta.2", -1},
|
||||
{"4.2-beta", "4.2-beta.foo", 1},
|
||||
{"4.2-beta.2", "4.2-beta", 1},
|
||||
{"4.2-beta.foo", "4.2-beta", -1},
|
||||
{"1.2+bar", "1.2+baz", 0},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
v2, err := NewVersion(tc.v2)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
a := v1.Compare(v2)
|
||||
e := tc.expected
|
||||
if a != e {
|
||||
t.Errorf(
|
||||
"Comparison of '%s' and '%s' failed. Expected '%d', got '%d'",
|
||||
tc.v1, tc.v2, e, a,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLessThan(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
v2 string
|
||||
expected bool
|
||||
}{
|
||||
{"1.2.3", "1.5.1", true},
|
||||
{"2.2.3", "1.5.1", false},
|
||||
{"3.2-beta", "3.2-beta", false},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
v2, err := NewVersion(tc.v2)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
a := v1.LessThan(v2)
|
||||
e := tc.expected
|
||||
if a != e {
|
||||
t.Errorf(
|
||||
"Comparison of '%s' and '%s' failed. Expected '%t', got '%t'",
|
||||
tc.v1, tc.v2, e, a,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGreaterThan(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
v2 string
|
||||
expected bool
|
||||
}{
|
||||
{"1.2.3", "1.5.1", false},
|
||||
{"2.2.3", "1.5.1", true},
|
||||
{"3.2-beta", "3.2-beta", false},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
v2, err := NewVersion(tc.v2)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
a := v1.GreaterThan(v2)
|
||||
e := tc.expected
|
||||
if a != e {
|
||||
t.Errorf(
|
||||
"Comparison of '%s' and '%s' failed. Expected '%t', got '%t'",
|
||||
tc.v1, tc.v2, e, a,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEqual(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
v2 string
|
||||
expected bool
|
||||
}{
|
||||
{"1.2.3", "1.5.1", false},
|
||||
{"2.2.3", "1.5.1", false},
|
||||
{"3.2-beta", "3.2-beta", true},
|
||||
{"3.2-beta+foo", "3.2-beta+bar", true},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
v2, err := NewVersion(tc.v2)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
a := v1.Equal(v2)
|
||||
e := tc.expected
|
||||
if a != e {
|
||||
t.Errorf(
|
||||
"Comparison of '%s' and '%s' failed. Expected '%t', got '%t'",
|
||||
tc.v1, tc.v2, e, a,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInc(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
expected string
|
||||
how string
|
||||
expectedOriginal string
|
||||
}{
|
||||
{"1.2.3", "1.2.4", "patch", "1.2.4"},
|
||||
{"v1.2.4", "1.2.5", "patch", "v1.2.5"},
|
||||
{"1.2.3", "1.3.0", "minor", "1.3.0"},
|
||||
{"v1.2.4", "1.3.0", "minor", "v1.3.0"},
|
||||
{"1.2.3", "2.0.0", "major", "2.0.0"},
|
||||
{"v1.2.4", "2.0.0", "major", "v2.0.0"},
|
||||
{"1.2.3+meta", "1.2.4", "patch", "1.2.4"},
|
||||
{"1.2.3-beta+meta", "1.2.3", "patch", "1.2.3"},
|
||||
{"v1.2.4-beta+meta", "1.2.4", "patch", "v1.2.4"},
|
||||
{"1.2.3-beta+meta", "1.3.0", "minor", "1.3.0"},
|
||||
{"v1.2.4-beta+meta", "1.3.0", "minor", "v1.3.0"},
|
||||
{"1.2.3-beta+meta", "2.0.0", "major", "2.0.0"},
|
||||
{"v1.2.4-beta+meta", "2.0.0", "major", "v2.0.0"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
var v2 Version
|
||||
switch tc.how {
|
||||
case "patch":
|
||||
v2 = v1.IncPatch()
|
||||
case "minor":
|
||||
v2 = v1.IncMinor()
|
||||
case "major":
|
||||
v2 = v1.IncMajor()
|
||||
}
|
||||
|
||||
a := v2.String()
|
||||
e := tc.expected
|
||||
if a != e {
|
||||
t.Errorf(
|
||||
"Inc %q failed. Expected %q got %q",
|
||||
tc.how, e, a,
|
||||
)
|
||||
}
|
||||
|
||||
a = v2.Original()
|
||||
e = tc.expectedOriginal
|
||||
if a != e {
|
||||
t.Errorf(
|
||||
"Inc %q failed. Expected original %q got %q",
|
||||
tc.how, e, a,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetPrerelease(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
prerelease string
|
||||
expectedVersion string
|
||||
expectedPrerelease string
|
||||
expectedOriginal string
|
||||
expectedErr error
|
||||
}{
|
||||
{"1.2.3", "**", "1.2.3", "", "1.2.3", ErrInvalidPrerelease},
|
||||
{"1.2.3", "beta", "1.2.3-beta", "beta", "1.2.3-beta", nil},
|
||||
{"v1.2.4", "beta", "1.2.4-beta", "beta", "v1.2.4-beta", nil},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
v2, err := v1.SetPrerelease(tc.prerelease)
|
||||
if err != tc.expectedErr {
|
||||
t.Errorf("Expected to get err=%s, but got err=%s", tc.expectedErr, err)
|
||||
}
|
||||
|
||||
a := v2.Prerelease()
|
||||
e := tc.expectedPrerelease
|
||||
if a != e {
|
||||
t.Errorf("Expected prerelease value=%q, but got %q", e, a)
|
||||
}
|
||||
|
||||
a = v2.String()
|
||||
e = tc.expectedVersion
|
||||
if a != e {
|
||||
t.Errorf("Expected version string=%q, but got %q", e, a)
|
||||
}
|
||||
|
||||
a = v2.Original()
|
||||
e = tc.expectedOriginal
|
||||
if a != e {
|
||||
t.Errorf("Expected version original=%q, but got %q", e, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetMetadata(t *testing.T) {
|
||||
tests := []struct {
|
||||
v1 string
|
||||
metadata string
|
||||
expectedVersion string
|
||||
expectedMetadata string
|
||||
expectedOriginal string
|
||||
expectedErr error
|
||||
}{
|
||||
{"1.2.3", "**", "1.2.3", "", "1.2.3", ErrInvalidMetadata},
|
||||
{"1.2.3", "meta", "1.2.3+meta", "meta", "1.2.3+meta", nil},
|
||||
{"v1.2.4", "meta", "1.2.4+meta", "meta", "v1.2.4+meta", nil},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, err := NewVersion(tc.v1)
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing version: %s", err)
|
||||
}
|
||||
|
||||
v2, err := v1.SetMetadata(tc.metadata)
|
||||
if err != tc.expectedErr {
|
||||
t.Errorf("Expected to get err=%s, but got err=%s", tc.expectedErr, err)
|
||||
}
|
||||
|
||||
a := v2.Metadata()
|
||||
e := tc.expectedMetadata
|
||||
if a != e {
|
||||
t.Errorf("Expected metadata value=%q, but got %q", e, a)
|
||||
}
|
||||
|
||||
a = v2.String()
|
||||
e = tc.expectedVersion
|
||||
if e != a {
|
||||
t.Errorf("Expected version string=%q, but got %q", e, a)
|
||||
}
|
||||
|
||||
a = v2.Original()
|
||||
e = tc.expectedOriginal
|
||||
if a != e {
|
||||
t.Errorf("Expected version original=%q, but got %q", e, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOriginalVPrefix(t *testing.T) {
|
||||
tests := []struct {
|
||||
version string
|
||||
vprefix string
|
||||
}{
|
||||
{"1.2.3", ""},
|
||||
{"v1.2.4", "v"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
v1, _ := NewVersion(tc.version)
|
||||
a := v1.originalVPrefix()
|
||||
e := tc.vprefix
|
||||
if a != e {
|
||||
t.Errorf("Expected vprefix=%q, but got %q", e, a)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user