choktest

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package choktest provides test utilities for applications built on chok.

It eliminates the boilerplate of setting up in-memory databases, loggers, and stores that recurs in every test file. Typical usage:

func TestMyFeature(t *testing.T) {
    gdb := choktest.NewTestDB(t, &model.User{}, &model.Post{})
    s := store.New[model.Post](gdb, choktest.NopLogger())
    // ... test against s ...
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestDB

func NewTestDB(t *testing.T, models ...any) *gorm.DB

NewTestDB opens an in-memory SQLite database, auto-migrates all provided models, and registers a cleanup that closes the DB when the test finishes. Fails the test on any error.

func NewTestStore

func NewTestStore[T db.Modeler](t *testing.T, opts ...store.StoreOption) *store.Store[T]

NewTestStore creates a Store[T] backed by an in-memory SQLite DB with the model auto-migrated. This is the fastest path for unit- testing Store-backed business logic.

func NopLogger

func NopLogger() log.Logger

NopLogger returns a no-op logger suitable for test usage where log output should be suppressed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL