backendtest

package
v0.0.0-...-d9705e4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 6 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 backendtest checks the shared converge contract of backend.Backend implementations using backend-specific fakes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Suite

func Suite(t *testing.T, newFixture Factory)

Suite runs the one-shot converge contract against injected backends.

Types

type Factory

type Factory func(t *testing.T) Fixture

Factory builds a fresh Fixture over fresh fakes. Suite calls it once per subtest so no clause observes another's mutations.

type Fixture

type Fixture struct {
	// Backend is a fresh backend over fakes, with nothing installed.
	Backend backend.Backend

	// ValidConfig is a config the backend accepts.
	ValidConfig backend.Config

	// SecondConfig is another accepted config that differs from ValidConfig,
	// so a Set that replaces one with the other must write.
	SecondConfig backend.Config

	// Clean reports whether managed system DNS artifacts are absent.
	Clean func() (bool, error)

	// Snapshot returns a comparable representation of the fake system's DNS
	// state. Nil marks a backend that installs nothing.
	Snapshot func() (any, error)

	// Writes counts every host mutation the fakes observed, including cache
	// flushes and policy notifications. Nil marks a backend that installs
	// nothing, which skips the no-op check.
	Writes func() int

	// FailSideEffects, while armed, makes each owed side effect (a cache
	// flush or policy notification) fail. Nil skips the side-effect clauses.
	FailSideEffects func(fail bool)

	// FailInspection, while armed, makes each attempt fail while it inspects
	// the host, before it changes anything or reaches its side effects. Nil
	// skips the clauses that need it.
	FailInspection func(fail bool)
}

Fixture is what a backend test hands Suite: a live backend over fakes, a config it accepts, and observers of the fake system.

Jump to

Keyboard shortcuts

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