浏览代码

http2: remove use of DeepEqual for testing errors

Comparing errors using DeepEqual breaks if frame information
is added as proposed in golang/go#29934.

Updates golang/go#29934

Change-Id: Ia2eb3f5ae2bdeac322b34e12d8e732174b9bd355
Reviewed-on: https://go-review.googlesource.com/c/164517
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Brad Fitzpatrick 6 年之前
父节点
当前提交
92fc7df08a
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. 10 0
      http2/http2_test.go
  2. 1 1
      http2/server_test.go

+ 10 - 0
http2/http2_test.go

@@ -226,6 +226,16 @@ func waitErrCondition(waitFor, checkEvery time.Duration, fn func() error) error
 	return err
 	return err
 }
 }
 
 
+func equalError(a, b error) bool {
+	if a == nil {
+		return b == nil
+	}
+	if b == nil {
+		return a == nil
+	}
+	return a.Error() == b.Error()
+}
+
 // Tests that http2.Server.IdleTimeout is initialized from
 // Tests that http2.Server.IdleTimeout is initialized from
 // http.Server.{Idle,Read}Timeout. http.Server.IdleTimeout was
 // http.Server.{Idle,Read}Timeout. http.Server.IdleTimeout was
 // added in Go 1.8.
 // added in Go 1.8.

+ 1 - 1
http2/server_test.go

@@ -3526,7 +3526,7 @@ func TestCheckValidHTTP2Request(t *testing.T) {
 	}
 	}
 	for i, tt := range tests {
 	for i, tt := range tests {
 		got := checkValidHTTP2RequestHeaders(tt.h)
 		got := checkValidHTTP2RequestHeaders(tt.h)
-		if !reflect.DeepEqual(got, tt.want) {
+		if !equalError(got, tt.want) {
 			t.Errorf("%d. checkValidHTTP2Request = %v; want %v", i, got, tt.want)
 			t.Errorf("%d. checkValidHTTP2Request = %v; want %v", i, got, tt.want)
 		}
 		}
 	}
 	}