migrate from govendor to dep

This commit is contained in:
bergquist
2018-01-19 09:48:15 +01:00
parent 5bb22b836d
commit e023f79c5a
7349 changed files with 3153302 additions and 64302 deletions
+20 -14
View File
@@ -7,14 +7,15 @@ import (
"reflect"
"strings"
"github.com/smartystreets/assertions/internal/oglematchers"
"github.com/smartystreets/assertions/internal/go-render/render"
"github.com/smartystreets/assertions/internal/oglematchers"
)
// default acceptable delta for ShouldAlmostEqual
const defaultDelta = 0.0000000001
// ShouldEqual receives exactly two parameters and does an equality check.
// ShouldEqual receives exactly two parameters and does an equality check
// using the following semantics:
// 1. If the expected and actual values implement an Equal method in the form
// `func (this T) Equal(that T) bool` then call the method. If true, they are equal.
// 2. The expected and actual values are judged equal or not by oglematchers.Equals.
func ShouldEqual(actual interface{}, expected ...interface{}) string {
if message := need(1, expected); message != success {
return message
@@ -25,10 +26,17 @@ func shouldEqual(actual, expected interface{}) (message string) {
defer func() {
if r := recover(); r != nil {
message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual))
return
}
}()
if specification := newEqualityMethodSpecification(expected, actual); specification.IsSatisfied() {
if specification.AreEqual() {
return success
} else {
message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual)
return serializer.serialize(expected, actual, message)
}
}
if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil {
expectedSyntax := fmt.Sprintf("%v", expected)
actualSyntax := fmt.Sprintf("%v", actual)
@@ -37,14 +45,14 @@ func shouldEqual(actual, expected interface{}) (message string) {
} else {
message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual)
}
message = serializer.serialize(expected, actual, message)
return
return serializer.serialize(expected, actual, message)
}
return success
}
// ShouldNotEqual receives exactly two parameters and does an inequality check.
// See ShouldEqual for details on how equality is determined.
func ShouldNotEqual(actual interface{}, expected ...interface{}) string {
if fail := need(1, expected); fail != success {
return fail
@@ -95,7 +103,7 @@ func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64
delta, err := getFloat(expected[1])
if err != nil {
return 0.0, 0.0, 0.0, "delta must be a numerical type"
return 0.0, 0.0, 0.0, "The delta value " + err.Error()
}
deltaFloat = delta
@@ -104,15 +112,13 @@ func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64
}
actualFloat, err := getFloat(actual)
if err != nil {
return 0.0, 0.0, 0.0, err.Error()
return 0.0, 0.0, 0.0, "The actual value " + err.Error()
}
expectedFloat, err := getFloat(expected[0])
if err != nil {
return 0.0, 0.0, 0.0, err.Error()
return 0.0, 0.0, 0.0, "The comparison value " + err.Error()
}
return actualFloat, expectedFloat, deltaFloat, ""
@@ -139,7 +145,7 @@ func getFloat(num interface{}) (float64, error) {
numKind == reflect.Float64 {
return numValue.Float(), nil
} else {
return 0.0, errors.New("must be a numerical type, but was " + numKind.String())
return 0.0, errors.New("must be a numerical type, but was: " + numKind.String())
}
}