fix: address code review findings

This commit is contained in:
2026-07-19 20:06:41 +03:00
parent b21bf07208
commit 4da5ee5f8c
4 changed files with 13 additions and 12 deletions

View File

@@ -49,7 +49,7 @@ func main() {
cancel()
}()
app, err := NewApp(ctx, cfg)
app, err := NewApp(ctx, cfg, "naviwatcher.db")
if err != nil {
log.Fatalf("Failed to initialize application: %v", err)
}
@@ -63,9 +63,10 @@ func main() {
}
// NewApp initializes all application components: config, database, and MusicBrainz client.
func NewApp(ctx context.Context, cfg *config.Config) (*App, error) {
// Initialize database (uses default path or could be made configurable).
db, err := database.New("naviwatcher.db")
// dbPath is the SQLite database path (use ":memory:" for tests).
func NewApp(ctx context.Context, cfg *config.Config, dbPath string) (*App, error) {
// Initialize database.
db, err := database.New(dbPath)
if err != nil {
return nil, fmt.Errorf("failed to initialize database: %w", err)
}

View File

@@ -132,7 +132,7 @@ func TestNewApp_CreatesMusicBrainzClient(t *testing.T) {
}
ctx := context.Background()
app, err := NewApp(ctx, cfg)
app, err := NewApp(ctx, cfg, ":memory:")
if err != nil {
t.Fatalf("NewApp returned error: %v", err)
}
@@ -167,7 +167,7 @@ func TestNewApp_GracefulShutdown(t *testing.T) {
}
ctx := context.Background()
app, err := NewApp(ctx, cfg)
app, err := NewApp(ctx, cfg, ":memory:")
if err != nil {
t.Fatalf("NewApp returned error: %v", err)
}
@@ -195,7 +195,7 @@ func TestAppRun_GracefulShutdown(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
app, err := NewApp(ctx, cfg)
app, err := NewApp(ctx, cfg, ":memory:")
if err != nil {
t.Fatalf("NewApp returned error: %v", err)
}