Repository: zeromicro/go-zero
Pull request #2752 (2023-01-04 04:46:04)

chore: improve codecov

codecov-commenter: # [Codecov](https://codecov.io/gh/zeromicro/go-zero/pull/2752?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#2752](https://codecov.io/gh/zeromicro/go-zero/pull/2752?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (604c4d2) into [master](https://codecov.io/gh/zeromicro/go-zero/commit/641ebf166780d418389acc00df48da3ae601a774?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (641ebf1) will **increase** coverage by `0.07%`.
> The diff coverage is `n/a`.


| [Impacted Files](https://codecov.io/gh/zeromicro/go-zero/pull/2752?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [rest/handler/tracinghandler.go](https://codecov.io/gh/zeromicro/go-zero/pull/2752/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cmVzdC9oYW5kbGVyL3RyYWNpbmdoYW5kbGVyLmdv) | `100.00% <ø> (+18.64%)` | :arrow_up: |
| [core/stores/sqlx/tx.go](https://codecov.io/gh/zeromicro/go-zero/pull/2752/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29yZS9zdG9yZXMvc3FseC90eC5nbw==) | `19.41% <0.00%> (-3.89%)` | :arrow_down: |
| [core/logx/rotatelogger.go](https://codecov.io/gh/zeromicro/go-zero/pull/2752/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29yZS9sb2d4L3JvdGF0ZWxvZ2dlci5nbw==) | `72.69% <0.00%> (+1.10%)` | :arrow_up: |
| [core/stores/sqlx/sqlconn.go](https://codecov.io/gh/zeromicro/go-zero/pull/2752/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29yZS9zdG9yZXMvc3FseC9zcWxjb25uLmdv) | `57.84% <0.00%> (+1.47%)` | :arrow_up: |


Patch:
diff --git a/rest/handler/tracinghandler.go b/rest/handler/tracinghandler.go
index 7d6b285f..43ad9d2c 100644
--- a/rest/handler/tracinghandler.go
+++ b/rest/handler/tracinghandler.go
@@ -17,9 +17,7 @@ import (
 	oteltrace "go.opentelemetry.io/otel/trace"
 )
 
-const (
-	traceKeyStatusCode = "http.status_code"
-)
+const traceKeyStatusCode = "http.status_code"
 
 var notTracingSpans sync.Map
 


Test patch:
diff --git a/rest/handler/tracinghandler_test.go b/rest/handler/tracinghandler_test.go
index 79a94c4d..d4aebe2a 100644
--- a/rest/handler/tracinghandler_test.go
+++ b/rest/handler/tracinghandler_test.go
@@ -148,3 +148,46 @@ func TestTraceResponseWriter(t *testing.T) {
 		})
 	}
 }
+
+func TestTraceHandler_traceResponseWriter(t *testing.T) {
+	writer := &traceResponseWriter{
+		w: httptest.NewRecorder(),
+	}
+	assert.NotPanics(t, func() {
+		writer.Hijack()
+	})
+
+	writer = &traceResponseWriter{
+		w: mockedHijackable{httptest.NewRecorder()},
+	}
+	assert.NotPanics(t, func() {
+		writer.Hijack()
+	})
+
+	writer = &traceResponseWriter{
+		w: httptest.NewRecorder(),
+	}
+	writer.WriteHeader(http.StatusBadRequest)
+	assert.NotNil(t, writer.Header())
+
+	writer = &traceResponseWriter{
+		w: httptest.NewRecorder(),
+	}
+	assert.NotPanics(t, func() {
+		writer.Flush()
+	})
+
+	writer = &traceResponseWriter{
+		w: mockedFlusher{httptest.NewRecorder()},
+	}
+	assert.NotPanics(t, func() {
+		writer.Flush()
+	})
+}
+
+type mockedFlusher struct {
+	*httptest.ResponseRecorder
+}
+
+func (m mockedFlusher) Flush() {
+}