- 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>
36 lines
No EOL
727 B
Go
36 lines
No EOL
727 B
Go
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
|
|
} |