Documentation
¶
Overview ¶
Package test provides a shared test harness for gosuki CLI and database tests.
All e2e and integration tests should use this harness to create isolated, reproducible test environments with known seed data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Harness ¶
type Harness struct {
DBPath string // Path to temp SQLite database file
Dir string // Temp directory (auto-cleaned by testing.T)
DB *db.DB // Initialized database handle
}
Harness holds test resources that need cleanup.
func NewHarness ¶
NewHarness creates a fresh test database with schema initialized.
It uses t.TempDir() for automatic cleanup on test completion and the in-memory-to-disk backup pattern from the existing test suite.
The returned harness has a fully initialized database (schema v4) ready for seeding. Call h.SeedBookmarks() to populate it with test data.
func NewHarnessWithSeed ¶
func NewHarnessWithSeed(t testing.TB, bookmarks []fixtures.SeedBookmark) *Harness
NewHarnessWithSeed is a convenience that creates a harness and seeds it in one call.
func (*Harness) Cleanup ¶
func (h *Harness) Cleanup()
Cleanup closes the database handle. The temp directory is auto-cleaned by testing.T when the test completes.
func (*Harness) SeedAndCount ¶
func (h *Harness) SeedAndCount(bookmarks []fixtures.SeedBookmark) int
SeedAndCount is a convenience method that seeds bookmarks and returns the total row count in gskbookmarks. Useful for verifying insertion.
func (*Harness) SeedBookmarks ¶
func (h *Harness) SeedBookmarks(bookmarks []fixtures.SeedBookmark) int
SeedBookmarks inserts bookmarks into the test database. Returns the number of bookmarks inserted. Panics on SQL errors (tests should not recover from seed failures).