Copilot commented on code in PR #3119:
URL: https://github.com/apache/dubbo-go/pull/3119#discussion_r2637578678
##########
logger/logger_test.go:
##########
@@ -58,3 +58,34 @@ func TestSetLoggerLevel(t *testing.T) {
t.Fatalf("expected level 'warn', got %q", m.level)
}
}
+
+// simpleLogger implements Logger but NOT OpsLogger
+type simpleLogger struct{}
+
+func (s *simpleLogger) Debug(args ...any) {}
+func (s *simpleLogger) Debugf(template string, args ...any) {}
+func (s *simpleLogger) Info(args ...any) {}
+func (s *simpleLogger) Infof(template string, args ...any) {}
+func (s *simpleLogger) Warn(args ...any) {}
+func (s *simpleLogger) Warnf(template string, args ...any) {}
+func (s *simpleLogger) Error(args ...any) {}
+func (s *simpleLogger) Errorf(template string, args ...any) {}
+func (s *simpleLogger) Fatal(args ...any) {}
+func (s *simpleLogger) Fatalf(fmt string, args ...any) {}
+
+func TestSetLoggerLevel_NotOpsLogger(t *testing.T) {
+ s := &simpleLogger{}
+ SetLogger(s)
+ ok := SetLoggerLevel("debug")
+ if ok {
+ t.Fatalf("expected SetLoggerLevel to return false for
non-OpsLogger")
+ }
+}
+
+func TestGetLogger_ReturnsSetLogger(t *testing.T) {
+ s := &simpleLogger{}
+ SetLogger(s)
+ if GetLogger() != s {
+ t.Fatalf("GetLogger should return the logger set by SetLogger")
+ }
+}
Review Comment:
This test duplicates the functionality already covered by
TestSetAndGetLogger (lines 42-48). Both tests verify that GetLogger returns the
logger set by SetLogger. The only difference is the logger type used
(simpleLogger vs mockLogger), but since both implement the Logger interface and
the test is not exercising OpsLogger-specific behavior, this test provides
redundant coverage. Consider removing this test to avoid duplication.
```suggestion
```
--
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]