testcoverage

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func ConfigFromFile

func ConfigFromFile(cfg *Config, filename string) error

func CoveredPercentage added in v2.5.0

func CoveredPercentage(total, covered int64) int

func GenerateAndSaveBadge added in v2.8.0

func GenerateAndSaveBadge(w io.Writer, cfg Config, totalCoverage int) 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) error

Types

type AnalyzeResult

type AnalyzeResult struct {
	Threshold              Threshold
	FilesBelowThreshold    []CoverageStats
	PackagesBelowThreshold []CoverageStats
	MeetsTotalCoverage     bool
	TotalCoverage          int
}

func Analyze

func Analyze(cfg Config, coverageStats []CoverageStats) AnalyzeResult

func Check

func Check(w io.Writer, cfg Config) (AnalyzeResult, error)

func (*AnalyzeResult) Pass

func (r *AnalyzeResult) Pass() bool

type Badge added in v2.8.0

type Badge struct {
	FileName string
	CDN      CDN
	Git      Git
}

type CDN added in v2.8.0

type CDN struct {
	Key            string
	Secret         string
	Region         string
	FileName       string
	BucketName     string
	Endpoint       string
	ForcePathStyle bool
}

type Config

type Config struct {
	Profile            string     `yaml:"profile"`
	LocalPrefix        string     `yaml:"local-prefix"`
	Threshold          Threshold  `yaml:"threshold"`
	Override           []Override `yaml:"override,omitempty"`
	Exclude            Exclude    `yaml:"exclude"`
	GithubActionOutput bool       `yaml:"github-action-output"`
	Badge              Badge      `yaml:"-"`
}

func (Config) Validate

func (c Config) Validate() error

type CoverageStats

type CoverageStats struct {
	Name      string
	Total     int64
	Covered   int64
	Threshold int
}

func GenerateCoverageStats

func GenerateCoverageStats(cfg Config) ([]CoverageStats, error)

func (*CoverageStats) CoveredPercentage

func (s *CoverageStats) CoveredPercentage() int

type Exclude added in v2.6.0

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

type FuncExtent

type FuncExtent struct {
	// contains filtered or unexported fields
}

FuncExtent describes a function's extent in the source by file and position.

type FuncVisitor

type FuncVisitor struct {
	// contains filtered or unexported fields
}

FuncVisitor implements the visitor that builds the function position list for a file.

func (*FuncVisitor) Visit

func (v *FuncVisitor) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface.

type Git added in v2.8.0

type Git struct {
	Token      string
	Owner      string
	Repository string
	Branch     string
	FileName   string
}

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