augmenttest

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 5 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 augmenttest is the test double for the scanner's Augmenter seam (iss-2608291814575788): a fake augmenter that flags one fixed value the native pattern set does not see, a not-found augmenter, and Install, which registers either as the default every scanner.New picks up. It spawns no process and needs no gitleaks binary, so a consumer's test proves the consumer reports what an augmenter found, and behaves on the not-found gap, without any external tool.

Index

Constants

View Source
const Kind = "fake:augmented"

Kind is the kind the fake reports.

View Source
const Value = "plumbob-harvest-quiet-lantern"

Value is the value the fake flags. It is lowercase words joined by hyphens, which no native pattern matches, so a finding for it can only have come from the augmenter; it is not token-shaped.

Variables

This section is empty.

Functions

func Install

func Install(t testing.TB, a scanner.Augmenter)

Install registers a as the default augmenter every scanner.New wires for the rest of the test. A test that installs one must not run in parallel with another that builds a scanner.

func Locate

func Locate(text, file, value, kind string) []scanner.Finding

Locate returns a finding for every occurrence of value in text, the way a real augmenter must (every occurrence, so a write path can verify it by its bytes).

Types

type Func

type Func struct {
	F   func(text, file string) ([]scanner.Finding, error)
	Err error
	// contains filtered or unexported fields
}

Func is an Augmenter built from a scan function: Scan calls F, and an error F returns is kept and reported by Available from then on, the way the gitleaks augmenter keeps a failed run. Err, set before use, is Available's answer from the start (ErrNotFound for the gap).

func Fake

func Fake() *Func

Fake returns an augmenter that flags every occurrence of Value.

func NotFound

func NotFound() *Func

NotFound returns an augmenter the repository configured whose tool is not installed: Available matches scanner.ErrAugmenterNotFound, and it never scans.

func (*Func) Available

func (f *Func) Available() error

Available reports Err, or the error of the last failed Scan.

func (*Func) Calls

func (f *Func) Calls() int

Calls is how many times Scan ran.

func (*Func) Scan

func (f *Func) Scan(text, file string) []scanner.Finding

Scan runs F.

Jump to

Keyboard shortcuts

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