suite

package module
v0.0.0-...-184e3b3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 33 Imported by: 2

Documentation

Overview

Package suite provides a suite for running compatibility tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(tb testing.TB, opts ...Option)

Run creates a new test suite and run it.

Types

type CustomerRepositoryConstructor

type CustomerRepositoryConstructor func(db DatabaseExecer, c clock.Clock) customer.Repository

CustomerRepositoryConstructor is constructor to create a new repository using DatabaseContext.

type DatabaseContext

type DatabaseContext interface {
	PreparerContext
	ExecerContext
	QueryerContext
}

DatabaseContext is a set of PreparerContext, ExecerContext, QueryerContext.

type DatabaseExecer

type DatabaseExecer interface {
	Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) (*sql.Row, error)
}

DatabaseExecer executes query depends on what it has.

type ExecerContext

type ExecerContext interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

ExecerContext executes a query without returning any rows.

type Option

type Option func(*suite)

Option sets up the test suite.

func WithCustomerRepositoryConstructor

func WithCustomerRepositoryConstructor(c CustomerRepositoryConstructor) Option

WithCustomerRepositoryConstructor sets the constructor.

func WithDatabaseDSN

func WithDatabaseDSN(dsn string) Option

WithDatabaseDSN sets the database dsn.

func WithDatabaseDriver

func WithDatabaseDriver(driver string) Option

WithDatabaseDriver sets the database driver.

func WithDatabasePlaceholderFormat

func WithDatabasePlaceholderFormat(format squirrel.PlaceholderFormat) Option

WithDatabasePlaceholderFormat sets the database placeholder format.

func WithFeatureFilesLocation

func WithFeatureFilesLocation(loc string) Option

WithFeatureFilesLocation sets the feature files location.

func WithTestContainerRequests

func WithTestContainerRequests(requests ...testcontainers.StartGenericContainerRequest) Option

WithTestContainerRequests appends container requests.

type PreparerContext

type PreparerContext interface {
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

PreparerContext creates a prepared statement for later queries or executions.

type QueryerContext

type QueryerContext interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

QueryerContext executes a query that returns rows, typically a SELECT.

type Suite

type Suite interface {
	Run(tb testing.TB)
}

Suite is a test suite.

func New

func New(opts ...Option) Suite

New creates a new test suite.

Directories

Path Synopsis
Package customer provides definition for customer domain.
Package customer provides definition for customer domain.

Jump to

Keyboard shortcuts

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