testcoverage

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const HiddenValue = "***"

Variables

View Source
var (
	ErrThresholdNotInRange         = errors.New("threshold must be in range [0 - 100]")
	ErrCoverageProfileNotSpecified = errors.New("coverage profile file not specified")
	ErrRegExpNotValid              = errors.New("regular expression is not valid")
	ErrCDNOptionNotSet             = errors.New("CDN options are not valid")
	ErrGitOptionNotSet             = errors.New("git options are not valid")
)

Functions

func Check

func Check(wout io.Writer, cfg Config) (bool, error)

func ConfigFromFile

func ConfigFromFile(cfg *Config, filename string) error

func GenerateCoverageStats

func GenerateCoverageStats(cfg Config) ([]coverage.Stats, error)

func ReportForGithubAction

func ReportForGithubAction(w io.Writer, result AnalyzeResult)

func ReportForHuman

func ReportForHuman(w io.Writer, result AnalyzeResult)

func SetGithubActionOutput

func SetGithubActionOutput(result AnalyzeResult, report string) error

func TotalLinesMissingCoverage added in v2.16.0

func TotalLinesMissingCoverage(diff []FileCoverageDiff) int

func TotalPercentageDiff added in v2.16.0

func TotalPercentageDiff(current, base []coverage.Stats) float64

Types

type AnalyzeResult

type AnalyzeResult struct {
	Threshold               Threshold
	DiffThreshold           *float64
	FilesBelowThreshold     []coverage.Stats
	PackagesBelowThreshold  []coverage.Stats
	FilesWithUncoveredLines []coverage.Stats
	TotalStats              coverage.Stats
	HasBaseBreakdown        bool
	Diff                    []FileCoverageDiff
	DiffPercentage          float64
	HasFileOverrides        bool
	HasPackageOverrides     bool
}

func Analyze

func Analyze(cfg Config, current, base []coverage.Stats) AnalyzeResult

func (*AnalyzeResult) MeetsDiffThreshold added in v2.16.0

func (r *AnalyzeResult) MeetsDiffThreshold() bool

func (*AnalyzeResult) MeetsTotalCoverage

func (r *AnalyzeResult) MeetsTotalCoverage() bool

func (*AnalyzeResult) Pass

func (r *AnalyzeResult) Pass() bool

type Badge added in v2.8.0

type Badge struct {
	FileName string
	CDN      badgestorer.CDN
	Git      badgestorer.Git
}

type Config

type Config struct {
	Profile               string     `yaml:"profile"`
	Debug                 bool       `yaml:"-"`
	LocalPrefixDeprecated string     `yaml:"-"`
	SourceDir             string     `yaml:"-"`
	Threshold             Threshold  `yaml:"threshold"`
	Override              []Override `yaml:"override,omitempty"`
	Exclude               Exclude    `yaml:"exclude"`
	BreakdownFileName     string     `yaml:"breakdown-file-name"`
	GithubActionOutput    bool       `yaml:"github-action-output"`
	Diff                  Diff       `yaml:"diff"`
	Badge                 Badge      `yaml:"-"`
}

func (Config) Redacted added in v2.14.1

func (c Config) Redacted() Config

func (Config) Validate

func (c Config) Validate() error

type Diff added in v2.11.0

type Diff struct {
	BaseBreakdownFileName string   `yaml:"base-breakdown-file-name"`
	Threshold             *float64 `yaml:"threshold,omitempty"`
}

type Exclude added in v2.6.0

type Exclude struct {
	Paths []string `yaml:"paths,omitempty"`
}

type FileCoverageDiff added in v2.11.0

type FileCoverageDiff struct {
	Current coverage.Stats
	Base    *coverage.Stats
}

type Override added in v2.7.0

type Override struct {
	Threshold int    `yaml:"threshold"`
	Path      string `yaml:"path"`
}

type Threshold

type Threshold struct {
	File    int `yaml:"file"`
	Package int `yaml:"package"`
	Total   int `yaml:"total"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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