From de96851d8eb0a0b45d7bf0cee67339fea54349f0 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Thu, 12 Feb 2026 21:35:46 -0800 Subject: wip: tui updates (buggy) --- models/db_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'models/db_test.go') diff --git a/models/db_test.go b/models/db_test.go index 08ceb44..8c61d20 100644 --- a/models/db_test.go +++ b/models/db_test.go @@ -1,6 +1,7 @@ package models import ( + "path/filepath" "testing" "adammathes.com/neko/config" @@ -33,11 +34,21 @@ func TestInitDB(t *testing.T) { } } -// SetupTestDB initializes an in-memory SQLite database for testing. -// Call this from other packages' tests to get a working DB. +func TestInitDBError(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("InitDB should panic for invalid DB file") + } + }() + // Using a directory path instead of a file should cause a failure in Ping + config.Config.DBFile = t.TempDir() + InitDB() +} + +// SetupTestDB initializes an isolated SQLite database for testing. func SetupTestDB(t *testing.T) { t.Helper() - config.Config.DBFile = ":memory:" + config.Config.DBFile = filepath.Join(t.TempDir(), "test.db") InitDB() t.Cleanup(func() { if DB != nil { -- cgit v1.2.3