test: Add comprehensive test suite for database functionality
- Add unit tests for database operations and optimization - Test external data source loading and caching - Add callsign manager functionality tests - Create test helpers for database testing utilities - Ensure database reliability and performance validation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
0f16748224
commit
5733209251
5 changed files with 955 additions and 0 deletions
36
internal/database/test_helpers.go
Normal file
36
internal/database/test_helpers.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// setupTestDatabase creates a temporary database for testing
|
||||
func setupTestDatabase(t *testing.T) (*Database, func()) {
|
||||
tempFile, err := os.CreateTemp("", "test_skyview_*.db")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temp database file:", err)
|
||||
}
|
||||
tempFile.Close()
|
||||
|
||||
config := &Config{Path: tempFile.Name()}
|
||||
db, err := NewDatabase(config)
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create database:", err)
|
||||
}
|
||||
|
||||
// Initialize the database (run migrations)
|
||||
err = db.Initialize()
|
||||
if err != nil {
|
||||
db.Close()
|
||||
os.Remove(tempFile.Name())
|
||||
t.Fatal("Failed to initialize database:", err)
|
||||
}
|
||||
|
||||
cleanup := func() {
|
||||
db.Close()
|
||||
os.Remove(tempFile.Name())
|
||||
}
|
||||
|
||||
return db, cleanup
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue