Inject Config as dependency for database, routing table, and snapshotter

- Remove old database Config struct and related functions
- Update database.New() to accept config.Config parameter
- Update routingtable.New() to accept config.Config parameter
- Update snapshotter.New() to accept config.Config parameter
- Simplify fx module providers in app.go
- Fix truthiness check for environment variables
- Handle empty state directory gracefully in routing table and snapshotter
- Update all tests to use empty state directory for testing
This commit is contained in:
2025-07-28 00:55:09 +02:00
parent 1a0622efaa
commit d15a5e91b9
7 changed files with 174 additions and 174 deletions
+9 -4
View File
@@ -7,6 +7,7 @@ import (
"testing"
"time"
"git.eeqj.de/sneak/routewatch/internal/config"
"git.eeqj.de/sneak/routewatch/internal/database"
"git.eeqj.de/sneak/routewatch/internal/metrics"
"git.eeqj.de/sneak/routewatch/internal/routingtable"
@@ -171,8 +172,14 @@ func TestRouteWatchLiveFeed(t *testing.T) {
// Create streamer
s := streamer.New(logger, metricsTracker)
// Create test config with empty state dir (no snapshot loading)
cfg := &config.Config{
StateDir: "",
MaxRuntime: 5 * time.Second,
}
// Create routing table
rt := routingtable.New(logger)
rt := routingtable.New(cfg, logger)
// Create server
srv := server.New(mockDB, rt, s, logger)
@@ -184,9 +191,7 @@ func TestRouteWatchLiveFeed(t *testing.T) {
Streamer: s,
Server: srv,
Logger: logger,
Config: Config{
MaxRuntime: 5 * time.Second,
},
Config: cfg,
}
rw := New(deps)