testdbversion

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testdbversion provides strict database-version selection for test fixtures and expectations. It is test infrastructure, not a support-policy API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Select

func Select[T any](dialect Dialect, rawVersion string, candidates []Expectation[T]) (T, error)

Select returns the only expectation matching rawVersion. Overlapping ranges fail instead of silently depending on declaration order.

Types

type Constraint

type Constraint struct {
	Exact        string `json:"exact,omitempty"`
	MinInclusive string `json:"min_inclusive,omitempty"`
	MaxExclusive string `json:"max_exclusive,omitempty"`
}

Constraint selects either one exact database version or a half-open range. Range bounds use [min_inclusive, max_exclusive).

func (Constraint) Match

func (constraint Constraint) Match(dialect Dialect, raw string) (bool, error)

Match reports whether raw belongs to the exact version or half-open range.

type Dialect

type Dialect string

Dialect identifies the database versioning scheme used by a fixture.

const (
	// MySQL uses major.minor.patch server versions.
	MySQL Dialect = "mysql"
	// PostgreSQL uses major.minor versions for supported releases 16 and 17.
	PostgreSQL Dialect = "postgresql"
)

type Expectation

type Expectation[T any] struct {
	Versions Constraint `json:"versions"`
	Value    T          `json:"value"`
}

Expectation associates a value with one unambiguous version constraint.

type Version

type Version struct {
	Dialect Dialect
	Major   int
	Minor   int
	Patch   int
	Parts   int
	Raw     string
}

Version is the normalized numeric part of a server version. Vendor suffixes are retained in Raw for diagnostics but never participate in comparison.

func Parse

func Parse(dialect Dialect, raw string) (Version, error)

Parse extracts and validates the comparable numeric server version.

func (Version) Canonical

func (version Version) Canonical() string

Canonical returns the normalized version without vendor suffixes.

Jump to

Keyboard shortcuts

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