providertest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package providertest is the conformance suite every provider.Provider must pass. A provider's own tests call Run with a constructor.

func TestConformance(t *testing.T) {
	providertest.Run(t, func() provider.Provider { return newTestProvider() })
}

The suite checks the contract on the Provider interface: version handling, binding of the additional data, typed errors, context cancellation, that inputs are not retained, that errors carry no key material, and concurrent use. It uses only the interface, so it applies to a local keyring and to a managed service alike.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newProvider func() provider.Provider)

Run runs every case as a subtest, each against a provider from newProvider.

Types

type Case

type Case struct {
	Name string
	Run  func(t TB, p provider.Provider)
}

Case is one conformance check. It runs against a fresh provider.

func Cases

func Cases() []Case

Cases returns the conformance cases.

type TB

type TB interface {
	Helper()
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
	Logf(format string, args ...any)
}

TB is the part of testing.TB the suite uses, so the suite can also run against a recorder to show that it rejects a broken provider.

Jump to

Keyboard shortcuts

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