Repository: go-kratos/kratos
Pull request #2770 (2023-03-29 10:42:20)

test: remove non-existent test methods
<!--
🎉 Thanks for sending a pull request to Kratos! Here are some tips for you:

1. If this is your first time contributing to Kratos, please read our contribution guide: https://go-kratos.dev/en/docs/community/contribution/
2. Ensure you have added or ran the appropriate tests and lint for your PR, please use `make lint` and `make test` before filing your PR, use `make clean` to tidy your go mod.
3. If the PR is unfinished, you may need to mark it as a WIP(Work In Progress) PR or Draft PR
4. Please use a semantic commits format title, such as `<type>[optional scope]: <description>`, see: https://go-kratos.dev/docs/community/contribution#type
5. at the same time, please note that similar work should be submitted in one PR as far as possible to reduce the workload of reviewers. Do not split a work into multiple PR unless it should.
-->

<!--
🎉 感谢您向 Kratos 发送 PR！以下是一些提示：
如果这是你第一次为 Kratos 贡献，请阅读我们的贡献指南：https://go-kratos.dev/en/docs/community/contribution/
2、确保您已经为您的 PR 添加或运行了适当的测试和lint，请在提交PR之前使用“make lint”和“make test”，使用“make clean”整理您的 go.mod。
3、如果 PR 未完成，您可能需要将其标记为 WIP（Work In Progress）PR 或 Draft PR
4、请使用语义提交格式标题，如“<类型>[可选范围]：<说明>`，请参阅：https://go-kratos.dev/docs/community/contribution#type
5. 同时请注意，同类的工作请尽量在一个PR中提交，以减轻 review 者的工作负担，不要把一项工作拆分成很多个PR，除非它应该这样做。
-->


#### Description (what this PR does / why we need it):
<!--
* The description should include the motivation for this PR or contrast this with previous behavior
-->


#### Which issue(s) this PR fixes (resolves / be part of):
<!--
* Automatically closes linked issue when PR is merged.
* If your PR is not fully resolved the issue, please use `part of #<issue number>` instead.

Usage: `fixes/resolves #<issue number>`, or `fixes/resolves (paste link of issue)`.
-->


#### Other special notes for the reviewers:
<!--
* Somethings that need extra attention for the reviewers
* Some additional notes, TODO list, etc.
-->


codecov-commenter: ## [Codecov](https://codecov.io/gh/go-kratos/kratos/pull/2770?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) Report
> Merging [#2770](https://codecov.io/gh/go-kratos/kratos/pull/2770?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) (8972fff) into [main](https://codecov.io/gh/go-kratos/kratos/commit/3958f9d5c06ec7a9d2b1a4c85d95688825b76ad4?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) (3958f9d) will **increase** coverage by `0.36%`.
> The diff coverage is `n/a`.

> :exclamation: Current head 8972fff differs from pull request most recent head 3430a04. Consider uploading reports for the commit 3430a04 to get more accurate results

:mega: This organization is not using Codecov’s [GitHub App Integration](https://github.com/apps/codecov). We recommend you install it so Codecov can continue to function properly for your repositories. [Learn more](https://about.codecov.io/blog/codecov-is-updating-its-github-integration/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)

```diff
@@            Coverage Diff             @@
##             main    #2770      +/-   ##
==========================================
+ Coverage   84.52%   84.88%   +0.36%     
==========================================
  Files          88       88              
  Lines        3923     3891      -32     
==========================================
- Hits         3316     3303      -13     
+ Misses        432      414      -18     
+ Partials      175      174       -1     
```


[see 7 files with indirect coverage changes](https://codecov.io/gh/go-kratos/kratos/pull/2770/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)

demoManito: @shenqidebaozi PTAL

Patch:
diff --git a/contrib/log/zap/zap.go b/contrib/log/zap/zap.go
index acf453fe..812afb95 100644
--- a/contrib/log/zap/zap.go
+++ b/contrib/log/zap/zap.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"go.uber.org/zap"
+	"go.uber.org/zap/zapcore"
 
 	"github.com/go-kratos/kratos/v2/log"
 )
@@ -32,6 +33,11 @@ func NewLogger(zlog *zap.Logger) *Logger {
 }
 
 func (l *Logger) Log(level log.Level, keyvals ...interface{}) error {
+	// If logging at this level is completely disabled, skip the overhead of
+	// string formatting.
+	if zapcore.Level(level) < zapcore.DPanicLevel && !l.log.Core().Enabled(zapcore.Level(level)) {
+		return nil
+	}
 	var (
 		msg    = ""
 		keylen = len(keyvals)


Test patch:
diff --git a/transport/http/client_test.go b/transport/http/client_test.go
index 25ae9a8e..ab3e83b6 100644
--- a/transport/http/client_test.go
+++ b/transport/http/client_test.go
@@ -42,6 +42,15 @@ func (x *mockCallOption) after(_ *callInfo, _ *csAttempt) {
 	log.Println("run in mockCallOption.after")
 }
 
+func TestWithSubset(t *testing.T) {
+	co := &clientOptions{}
+	o := WithSubset(1)
+	o(co)
+	if co.subsetSize != 1 {
+		t.Error("expected subset size to be 1")
+	}
+}
+
 func TestWithTransport(t *testing.T) {
 	ov := &mockRoundTripper{}
 	o := WithTransport(ov)
@@ -71,10 +80,6 @@ func TestWithBlock(t *testing.T) {
 	}
 }
 
-func TestWithBalancer(_ *testing.T) {
-	// TODO
-}
-
 func TestWithTLSConfig(t *testing.T) {
 	ov := &tls.Config{}
 	o := WithTLSConfig(ov)
diff --git a/transport/http/server_test.go b/transport/http/server_test.go
index 44477504..7bd31e86 100644
--- a/transport/http/server_test.go
+++ b/transport/http/server_test.go
@@ -308,10 +308,6 @@ func TestTimeout(t *testing.T) {
 	}
 }
 
-func TestLogger(_ *testing.T) {
-	// TODO
-}
-
 func TestRequestDecoder(t *testing.T) {
 	o := &Server{}
 	v := func(*http.Request, interface{}) error { return nil }