drivertest

package
v8.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package drivertest provides conformance tests for db implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunConformanceTests

func RunConformanceTests(t *testing.T, newHarness HarnessMaker[*testing.T])

RunConformanceTests runs conformance tests for driver implementations of the driver.DBFactory interface.

Types

type Harness

type Harness interface {
	// MakeAdapter makes a new adapter for the harness.
	// Adapter and tx should be considered valid if err is nil.
	MakeAdapter(context.Context) (adapter driver.DBFactory, tx *gorm.DB, err error)

	// Close closes resources used by the harness.
	Close()

	// Options returns the options for the harness.
	Options() Options
}

Harness descibes the functionality test harnesses must provide to run conformance tests.

type HarnessMaker

type HarnessMaker[TB testing.TB] func(ctx context.Context, t TB) (Harness, error)

HarnessMaker describes functions that construct a harness for running tests. It is called exactly once per test; Harness.Close() will be called when the test is complete.

type Options

type Options struct {
	// IsMock indicates if the driver is a mock implementation.
	// This is useful for mock implementations or drivers that do not support
	// the specific features required by the tests.
	IsMock bool

	// MaxConnectionsSQL specifies the SQL query to get the maximum number of connections.
	MaxConnectionsSQL string
}

Options is a set of options to configure driver specific behavior.

Jump to

Keyboard shortcuts

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