AlexStocks commented on code in PR #3471:
URL: https://github.com/apache/dubbo-go/pull/3471#discussion_r3533908701


##########
metrics/prometheus/registry_test.go:
##########
@@ -154,12 +152,12 @@ func TestPromMetricRegistryExport(t *testing.T) {
                err := 
http.ListenAndServe(url.GetParam(constant.PrometheusPushgatewayBaseUrlKey, ""),
                        http.HandlerFunc(func(w http.ResponseWriter, r 
*http.Request) {
                                bodyBytes, err := io.ReadAll(r.Body)
-                               assert.NoError(t, err)
+                               require.NoError(t, err)

Review Comment:
   [P1] 这里把 goroutine 内的断言从 `assert.NoError` 改成了 `require.NoError`,会触发 CI 中的 
`testifylint/go-require`:`require` 只能在运行测试函数的 goroutine 中使用。当前 PR 的 `CI 
(ubuntu-latest - Go 1.23)` 已经在 `metrics/prometheus/registry_test.go:155` 和 
`:160` 失败。这里需要改回非终止式断言,或把错误通过 channel 传回主测试 goroutine 后再用 `require` 断言。



##########
protocol/triple/dual_transport_test.go:
##########
@@ -134,17 +134,15 @@ func 
TestDualTransport_ConcurrentH2DiscoveryStartsSingleProbe(t *testing.T) {
 
        var wg sync.WaitGroup
        wg.Add(numRequests)
-       for i := 0; i < numRequests; i++ {
+       for range numRequests {
                req, err := http.NewRequest(http.MethodPost, 
"https://example.com/service";, nil)
                require.NoError(t, err)
 
                go func(req *http.Request) {
                        defer wg.Done()
 
                        resp, err := dt.RoundTrip(req)
-                       if !assert.NoError(t, err) {
-                               return
-                       }
+                       require.NoError(t, err)

Review Comment:
   [P1] 这个 `require.NoError` 位于新启动的 goroutine 内,违反 `testifylint/go-require` 
规则,并且当前 PR 的 CI 已经在这一行失败。`require` 会调用 `FailNow`,只能在测试主 goroutine 中使用;这里应改回 
`assert.NoError` 并 return,或把 `err` 发送到主 goroutine 后统一用 `require.NoError` 断言。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to