浏览代码

Merge pull request #40601 from thaJeztah/gotest_tools_v3.0.2

vendor: update gotest.tools v3.0.2
Akihiro Suda 5 年之前
父节点
当前提交
fd6da95585
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 1 1
      vendor.conf
  2. 11 6
      vendor/gotest.tools/v3/assert/assert.go

+ 1 - 1
vendor.conf

@@ -17,7 +17,7 @@ golang.org/x/sys                                    6d18c012aee9febd81bbf9806760
 github.com/docker/go-units                          519db1ee28dcc9fd2474ae59fca29a810482bfb1 # v0.4.0
 github.com/docker/go-connections                    7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0
 golang.org/x/text                                   f21a4dfb5e38f5895301dc265a8def02365cc3d0 # v0.3.0
-gotest.tools/v3                                     ab4a870b92ce57a83881fbeb535a137a20d664b7 # v3.0.1
+gotest.tools/v3                                     bb0d8a963040ea5048dcef1a14d8f8b58a33d4b3 # v3.0.2
 github.com/google/go-cmp                            3af367b6b30c263d47e8895973edcca9a49cf029 # v0.2.0
 github.com/syndtr/gocapability                      d98352740cb2c55f81556b63d4a1ec64c5a319c2
 

+ 11 - 6
vendor/gotest.tools/v3/assert/assert.go

@@ -119,12 +119,8 @@ func assert(
 		return true
 
 	case error:
-		// Handle nil structs which implement error as a nil error
-		if reflect.ValueOf(check).IsNil() {
-			return true
-		}
-		msg := "error is not nil: "
-		t.Log(format.WithCustomMessage(failureMessage+msg+check.Error(), msgAndArgs...))
+		msg := failureMsgFromError(check)
+		t.Log(format.WithCustomMessage(failureMessage+msg, msgAndArgs...))
 
 	case cmp.Comparison:
 		success = runComparison(t, argSelector, check, msgAndArgs...)
@@ -179,6 +175,15 @@ func logFailureFromBool(t TestingT, msgAndArgs ...interface{}) {
 	t.Log(format.WithCustomMessage(failureMessage+msg, msgAndArgs...))
 }
 
+func failureMsgFromError(err error) string {
+	// Handle errors with non-nil types
+	v := reflect.ValueOf(err)
+	if v.Kind() == reflect.Ptr && v.IsNil() {
+		return fmt.Sprintf("error is not nil: error has type %T", err)
+	}
+	return "error is not nil: " + err.Error()
+}
+
 func boolFailureMessage(expr ast.Expr) (string, error) {
 	if binaryExpr, ok := expr.(*ast.BinaryExpr); ok && binaryExpr.Op == token.NEQ {
 		x, err := source.FormatNode(binaryExpr.X)