Skip to content

Commit 033f4f1

Browse files
dorothyyzhclaude
andcommitted
fix(test): use plain gorm connection to avoid tracing output in Example tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 90d592c commit 033f4f1

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/stretchr/testify v1.11.1
1212
github.com/testcontainers/testcontainers-go/modules/redis v0.42.0
1313
golang.org/x/sync v0.20.0
14+
gorm.io/driver/postgres v1.6.0
1415
gorm.io/gorm v1.31.1
1516
)
1617

@@ -131,5 +132,4 @@ require (
131132
gopkg.in/yaml.v3 v3.0.1 // indirect
132133
gorm.io/datatypes v1.2.7 // indirect
133134
gorm.io/driver/mysql v1.5.6 // indirect
134-
gorm.io/driver/postgres v1.6.0 // indirect
135135
)

ratelimiter_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/theplant/ratelimiter"
1616
"github.com/theplant/ratelimiter/redisrl"
1717
"github.com/theplant/ratelimiter/sqlrl"
18+
"gorm.io/driver/postgres"
1819
"gorm.io/gorm"
1920
)
2021

@@ -48,7 +49,11 @@ func TestMain(m *testing.M) {
4849
panic(fmt.Errorf("failed to get redis connection string: %w", err))
4950
}
5051

51-
db = testSuite.DB()
52+
// Use a plain gorm connection without tracing to avoid polluting Example test output
53+
db, err = gorm.Open(postgres.Open(testSuite.DSN()), &gorm.Config{})
54+
if err != nil {
55+
log.Fatalf("Failed to open plain DB: %v", err)
56+
}
5257
redisCli = redis.NewClient(&redis.Options{
5358
Addr: strings.TrimPrefix(endpoint, "redis://"),
5459
})

0 commit comments

Comments
 (0)