testutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers for integration and e2e tests.

Helpers in this package assume they are invoked from within a Ginkgo spec and fail the spec directly via Gomega assertions instead of returning errors. Each helper calls GinkgoHelper() so failures are attributed to the caller.

Cycle-bound helpers (that depend on internal/db) live in the dbtest/ subpackage so the root testutil package stays import-clean and can be used by auth/config/db test suites without cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallSlog

func InstallSlog() func()

InstallSlog swaps slog.Default to a text handler writing to GinkgoWriter (so records appear inline with spec output only on failure / -v mode) and returns a restore func. Intended for use in BeforeSuite:

var _ = BeforeSuite(func() { DeferCleanup(testutil.InstallSlog()) })

Debug level is used so nothing in the package being tested gets filtered.

func MockEntClient

func MockEntClient() (*ent.Client, sqlmock.Sqlmock)

MockEntClient returns an *ent.Client backed by a go-sqlmock driver plus the sqlmock.Sqlmock handle used to register query/exec expectations.

Use this for tests that need to drive specific DB-layer errors (Count fails, Create fails, Rollback fails, etc.) into ent-using services — scenarios that a real in-memory SQLite cannot produce on demand.

The caller is responsible for closing the client (typically via DeferCleanup) and asserting mock.ExpectationsWereMet() at the end of the spec if strict ordering matters.

Types

This section is empty.

Directories

Path Synopsis
Package configtest provides config-singleton setup helpers for tests.
Package configtest provides config-singleton setup helpers for tests.
Package dbtest provides database-layer test helpers.
Package dbtest provides database-layer test helpers.

Jump to

Keyboard shortcuts

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