fixtures

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fixtures provides simple SQL fixture loading from embedded filesystems.

All fixture files MUST follow the timestamp naming convention: YYYYMMDDHHmmss_name.sql

Files are executed in chronological order within a single transaction.

Basic Usage

//go:embed fixtures
var fixturesFS embed.FS

func main() {
    if err := fixtures.Load(context.Background(), fixturesFS); err != nil {
        log.Fatal(err)
    }
}

Naming Convention

Fixture files MUST be named with a timestamp prefix (YYYYMMDDHHmmss):

  • 20250123120000_create_users.sql
  • 20250123120100_create_posts.sql
  • 20250123120200_seed_data.sql

This follows the same pattern as database migrations, ensuring chronological ordering and avoiding numbering conflicts.

Transaction Guarantee

All fixtures are loaded within a single transaction using the Transactioner interface. If any file fails, the entire operation is rolled back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(ctx context.Context, fixturesFS fs.FS) error

Load is a convenience function that creates DB from environment and loads fixtures.

func New

func New(db *sqldb.DBClient, opts ...option) (*loader, error)

New creates a new loader with the given database and options. DB parameter is required for explicit dependency management.

func WithLogger

func WithLogger(log logger.Logger) option

WithLogger sets a custom logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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