utests

package
v4.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utests defines util fns for Scorecard unit testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateLogMessage

func ValidateLogMessage(isExpectedMessage func(checker.LogMessage, checker.DetailType) bool,
	dl *TestDetailLogger,
) bool

ValidateLogMessage tests that at least one log message returns true for isExpectedMessage.

func ValidateLogMessageOffsets

func ValidateLogMessageOffsets(dl *TestDetailLogger, offsets []uint) bool

ValidateLogMessageOffsets tests that the log message offsets match those in the passed in slice.

func ValidatePinningDependencies added in v4.4.0

func ValidatePinningDependencies(isExpectedDependency func(checker.Dependency) bool,
	r *checker.PinningDependenciesData,
) bool

ValidatePinningDependencies tests that at least one entry returns true for isExpectedMessage.

func ValidateTestReturn

func ValidateTestReturn(
	t *testing.T,
	name string,
	expected *TestReturn,
	actual *checker.CheckResult,
	logger *TestDetailLogger,
) bool

ValidateTestReturn validates expected TestReturn with actual checker.CheckResult values. nolint: thelper

Types

type TestDetailLogger

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

TestDetailLogger implements `checker.DetailLogger`.

func (*TestDetailLogger) Debug

func (l *TestDetailLogger) Debug(msg *checker.LogMessage)

Debug implements DetailLogger.Debug.

func (*TestDetailLogger) Flush added in v4.1.0

func (l *TestDetailLogger) Flush() []checker.CheckDetail

Flush implements DetailLogger.Flush.

func (*TestDetailLogger) Info

func (l *TestDetailLogger) Info(msg *checker.LogMessage)

Info implements DetailLogger.Info.

func (*TestDetailLogger) Warn

func (l *TestDetailLogger) Warn(msg *checker.LogMessage)

Warn implements DetailLogger.Warn.

type TestReturn

type TestReturn struct {
	Error         error
	Score         int
	NumberOfWarn  int
	NumberOfInfo  int
	NumberOfDebug int
}

TestReturn encapsulates expected CheckResult return values.

Jump to

Keyboard shortcuts

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