Skip to content

Latest commit

 

History

History
86 lines (61 loc) · 1.2 KB

README.md

File metadata and controls

86 lines (61 loc) · 1.2 KB

Overview

Bunoffe is a small library to facilitate testing bun's queries. One should feel free to copy and paste it directly into the code he/she is working on.

Usage

Exec

Instead of writing

db := bun.NewDB(sqldb, sqlitedialect.New())

result, err := bundb.NewExec().
    Model(&m).
    Exec(ctx)

Do

db := bun.NewDB(sqldb, sqlitedialect.New())
executor := bunoffe.QueryRealizer{}

err := executor.Exec(
    ctx,
    bundb.NewExec().
        Model(&m),
)

Exists

Instead of writing

db := bun.NewDB(sqldb, sqlitedialect.New())

exists, err := bundb.NewSelect().
    Model(&m).
    Exists(ctx)

Do

db := bun.NewDB(sqldb, sqlitedialect.New())
executor := bunoffe.QueryRealizer{}

exists, err := executor.Exists(
    ctx,
    bundb.NewSelect().
        Model(&m),
)

Scan

Instead of writing

db := bun.NewDB(sqldb, sqlitedialect.New())

err := bundb.NewSelect().
    Model(&m).
    Scan(ctx)

Do

db := bun.NewDB(sqldb, sqlitedialect.New())
executor := bunoffe.QueryRealizer{}

err := executor.Scan(
    ctx,
    bundb.NewSelect().
        Model(&m),
)

Testing

Bunoffe provides a set mocked operations. Check it out.