Skip to content

Commit c082703

Browse files
fix: fixed issues based on the code review
1 parent 3a6a2cd commit c082703

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

internal/auditlog/auditlog_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7+
"fmt"
78
"io"
89
"strings"
910
"sync"
@@ -244,7 +245,7 @@ func TestLogger(t *testing.T) {
244245
// Write some entries
245246
for i := 0; i < 5; i++ {
246247
logger.Write(&LogEntry{
247-
ID: "entry-" + string(rune('0'+i)),
248+
ID: fmt.Sprintf("entry-%d", i),
248249
Timestamp: time.Now(),
249250
Model: "test-model",
250251
})

internal/storage/sqlite.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ func NewSQLite(cfg SQLiteConfig) (Storage, error) {
2828
}
2929

3030
// Open database with WAL mode and busy timeout
31-
// WAL mode allows concurrent reads while writing
3231
dsn := fmt.Sprintf("%s?_journal=WAL&_busy_timeout=5000&_synchronous=NORMAL", cfg.Path)
3332
db, err := sql.Open("sqlite", dsn)
3433
if err != nil {
3534
return nil, fmt.Errorf("failed to open SQLite database: %w", err)
3635
}
3736

38-
// Set connection pool settings for SQLite
39-
// SQLite doesn't benefit from multiple connections for writes,
40-
// but we allow some for concurrent reads
41-
db.SetMaxOpenConns(1) // SQLite only allows one writer at a time
37+
// Use a single connection to serialize all database access.
38+
// This prevents "database is locked" errors at the cost of no concurrent reads.
39+
db.SetMaxOpenConns(1)
4240
db.SetMaxIdleConns(1)
4341

4442
// Verify connection

tests/e2e/auditlog_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,11 @@ func TestAuditLogErrorCapture(t *testing.T) {
554554
}()
555555

556556
// Make a request with an unsupported model
557-
payload := map[string]interface{}{
558-
"model": "unsupported-model-xyz",
559-
"messages": []map[string]string{{"role": "user", "content": "Hello"}},
557+
payload := core.ChatRequest{
558+
Model: "unsupported-model-xyz",
559+
Messages: []core.Message{
560+
{Role: "user", Content: "Hello"},
561+
},
560562
}
561563
body, _ := json.Marshal(payload)
562564
resp, err := http.Post(serverURL+"/v1/chat/completions", "application/json", bytes.NewReader(body))

0 commit comments

Comments
 (0)