diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-12 21:35:46 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-12 21:35:46 -0800 |
| commit | de96851d8eb0a0b45d7bf0cee67339fea54349f0 (patch) | |
| tree | d9ca55835743e2254732ea68a674e7007f3554eb /models/db_test.go | |
| parent | 8a8f516ebd1115eed6256cd1b60be6393fd42c26 (diff) | |
| download | neko-de96851d8eb0a0b45d7bf0cee67339fea54349f0.tar.gz neko-de96851d8eb0a0b45d7bf0cee67339fea54349f0.tar.bz2 neko-de96851d8eb0a0b45d7bf0cee67339fea54349f0.zip | |
wip: tui updates (buggy)
Diffstat (limited to 'models/db_test.go')
| -rw-r--r-- | models/db_test.go | 17 |
1 files changed, 14 insertions, 3 deletions
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 { |
