Skip to content

Commit 8df2a2f

Browse files
committed
fix: unit tests
Former-commit-id: d369354 Former-commit-id: a955ae2ce4698a06c48270bab16ef6a688d755ed
1 parent ef8afe6 commit 8df2a2f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

mcp-server.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
64cc0aa69d3ec38779a297042faf233beea5c405
1+
63a866e3c565fc326675a4051e3074bf542a9b0f

pkg/dbtools/performance_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ import (
77
)
88

99
func TestPerformanceAnalyzer(t *testing.T) {
10-
// Create a new performance analyzer
11-
analyzer := NewPerformanceAnalyzer()
10+
// Get the global performance analyzer and reset it to ensure clean state
11+
analyzer := GetPerformanceAnalyzer()
12+
analyzer.Reset()
13+
14+
// Ensure we restore previous state after test
15+
defer func() {
16+
analyzer.Reset()
17+
}()
1218

1319
// Test tracking a query
1420
ctx := context.Background()
@@ -27,6 +33,9 @@ func TestPerformanceAnalyzer(t *testing.T) {
2733
t.Errorf("Expected result to be 'test result', got %v", result)
2834
}
2935

36+
// Add a small delay to ensure async metrics update completes
37+
time.Sleep(10 * time.Millisecond)
38+
3039
// Check metrics were collected
3140
metrics := analyzer.GetAllMetrics()
3241
if len(metrics) == 0 {
@@ -36,7 +45,7 @@ func TestPerformanceAnalyzer(t *testing.T) {
3645
// Find the test query in metrics
3746
var foundMetrics *QueryMetrics
3847
for _, m := range metrics {
39-
if m.Query == "SELECT * FROM test_table" {
48+
if normalizeQuery(m.Query) == normalizeQuery("SELECT * FROM test_table") {
4049
foundMetrics = m
4150
break
4251
}

0 commit comments

Comments
 (0)