feat: deprecated logger in client & add Logger in ClientOption (#738)
Fix #708 1. deprecated logger in client 2. add Logger in ClientOption 3. add unit test for Logger
This commit is contained in:
parent
e66c23fae4
commit
61be548803
1 changed files with 39 additions and 10 deletions
|
|
@ -7,6 +7,7 @@ package mcp
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
|
@ -165,6 +166,23 @@ func TestClientPaginateBasic(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestClientLogger(t *testing.T) {
|
||||
// Case 1: No logger provided
|
||||
c1 := NewClient(&Implementation{Name: "test", Version: "1.0"}, nil)
|
||||
if c1.opts.Logger == nil {
|
||||
t.Error("expected default logger, got nil")
|
||||
}
|
||||
|
||||
// Case 2: Logger provided
|
||||
logger := slog.Default()
|
||||
c2 := NewClient(&Implementation{Name: "test", Version: "1.0"}, &ClientOptions{
|
||||
Logger: logger,
|
||||
})
|
||||
if c2.opts.Logger != logger {
|
||||
t.Error("expected provided logger, got different one")
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientPaginateVariousPageSizes(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
for i := 1; i < len(allItems)+1; i++ {
|
||||
|
|
|
|||
Loading…
Reference in a new issue