uuid

package
v0.27.0-rc.16 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fix

func Fix(t interface{ Cleanup(func()) }, v string)

Fix makes Generate return v until t and its subtests finish, then puts back the backend it replaced. Calls nest: an inner Fix gives back the outer one when its test ends. The backend is process-global, so a test that calls Fix must not run in parallel with one that generates UUIDs.

func Generate

func Generate() string

Generate returns a new UUID v4 from the package's backend. Use it rather than the uuid package directly, so a test can make identifiers deterministic.

func Parse added in v0.24.1

func Parse(s string) (uuid.UUID, error)

Parse reads a UUID from its string form. It does not go through the backend: parsing has no behaviour worth substituting in a test.

func Set

func Set(t interface{ Cleanup(func()) }, u UUID)

Set serves Generate from u until t and its subtests finish, then puts back the backend it replaced. Use it when a test needs Generate to vary; Fix covers a single value. Like Fix, it swaps a process-global backend and is not safe under t.Parallel.

Types

type UUID

type UUID interface {
	Generate() string
}

UUID is an interface that can provide uuid related functionality which allows us to test uuid dependent code.

var DefaultBackend UUID

DefaultBackend is used to configure the defaultBackend.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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