deviations

package
v0.2.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 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 deviations loads and applies the file of accepted deviations between spec and API (FR-DEV).

Index

Constants

View Source
const WarnBefore = 14 * 24 * time.Hour

WarnBefore is how long before expiry an entry is reported as expiring soon (FR-DEV-05).

Variables

This section is empty.

Functions

func NormalizeCase

func NormalizeCase(name string) string

NormalizeCase turns a case name copied from go test output or an IDE into the name apitest matches: without the test function ("TestAPI/"), without the position prefix of Config.NumberCases ("007_") and with spaces as "_", like Go names subtests.

Types

type Entry

type Entry struct {
	Index int // position in the file, from 1

	// Case is the case name; "*" matches within one name element.
	Case string

	// Expected and Actual are status codes (e.g. 404 and 200).
	Expected, Actual string
	// Status is a result status such as EXAMPLE_MISMATCH, for deviations
	// that are not about the status code.
	Status string
	// Pointer limits Status to differences at exactly this JSON pointer.
	Pointer string

	Reason  string
	Ticket  string
	Expires time.Time
	// contains filtered or unexported fields
}

Entry is one accepted deviation.

func (*Entry) Describe

func (e *Entry) Describe() string

Describe is a short description for messages.

func (*Entry) Expired

func (e *Entry) Expired(now time.Time) bool

Expired reports whether the entry has expired at now.

func (*Entry) ExpiresSoon

func (e *Entry) ExpiresSoon(now time.Time) bool

ExpiresSoon reports whether the entry expires within WarnBefore.

func (*Entry) Rule

func (e *Entry) Rule() string

Rule describes what the entry accepts, e.g. "404 → 200" or "EXAMPLE_MISMATCH at /price".

type Outcome

type Outcome struct {
	Case     string
	Status   string   // e.g. FAILED
	Expected string   // expected status, e.g. "404"
	Actual   string   // actual status, e.g. "200"
	Pointers []string // locations of the differences, for status entries
}

Outcome describes a case result for matching.

type Set

type Set struct {
	Path    string
	Entries []*Entry
	// contains filtered or unexported fields
}

Set is a loaded deviations file.

func Load

func Load(p string) (*Set, error)

Load reads a deviations file (YAML or JSON). Invalid entries are rejected with their position (FR-DEV-02, NFR-08).

func (*Set) Match

func (s *Set) Match(o Outcome) *Entry

Match returns the first entry that matches o exactly (FR-DEV-01), or nil.

func (*Set) Near

func (s *Set) Near(name string) []*Entry

Near returns the entries that name the case but did not match its result, to explain why a deviation did not apply.

func (*Set) Uses

func (s *Set) Uses(e *Entry) int

Uses returns how often e matched.

Jump to

Keyboard shortcuts

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