testutil

package
v0.6.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IsTesting       = strings.HasSuffix(os.Args[0], ".test")
	IsGithubActions = os.Getenv("GITHUB_ACTIONS") == "true"
	IsDrone         = os.Getenv("DRONE") == "true"
	StdoutWriter    = lo.Ternary[io.Writer](IsTesting, ginkgo.GinkgoWriter, os.Stdout)
	StderrWriter    = lo.Ternary[io.Writer](IsTesting, ginkgo.GinkgoWriter, os.Stderr)
)
View Source
var EncoderConfig = zapcore.EncoderConfig{
	MessageKey:       "M",
	LevelKey:         "L",
	TimeKey:          "T",
	NameKey:          "N",
	CallerKey:        "C",
	FunctionKey:      "",
	StacktraceKey:    "S",
	ConsoleSeparator: " ",
	EncodeLevel:      zapcore.CapitalColorLevelEncoder,
	EncodeCaller: func(ec zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
		enc.AppendString(chalk.Dim.TextStyle(ec.TrimmedPath()))
	},
	EncodeName: func(name string, enc zapcore.PrimitiveArrayEncoder) {
		enc.AppendString(chalk.Dim.TextStyle(
			strings.Replace(name, "controller-runtime.manager.", "", 1)))
	},
	EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
		enc.AppendString(t.Format("[15:04:05]"))
	},
	EncodeDuration: zapcore.SecondsDurationEncoder,
}

Functions

func IfCI

func IfCI[T any](t T) ifExpr[T]

func IfTesting

func IfTesting[T any](t T) ifExpr[T]

func MergeCoverProfiles added in v0.4.2

func MergeCoverProfiles(filenames []string, output io.Writer, opts ...ProfileOption) error

func Must

func Must[T any](t T, err ...error) T

func NewTestLogger added in v0.6.0

func NewTestLogger() logr.Logger

func PortForward added in v0.5.4

func PortForward(
	ctx context.Context,
	service types.NamespacedName,
	servicePorts []string,
	restConfig *rest.Config,
	scheme *runtime.Scheme,
) ([]portforward.ForwardedPort, error)

func ProtoEqual added in v0.6.0

func ProtoEqual(expected proto.Message) types.GomegaMatcher

Types

type ProfileOption added in v0.4.2

type ProfileOption func(*ProfileOptions)

func WithExcludePatterns added in v0.4.2

func WithExcludePatterns(excludePatterns ...string) ProfileOption

func WithKeepMergedProfiles added in v0.4.2

func WithKeepMergedProfiles(keep bool) ProfileOption

type ProfileOptions added in v0.4.2

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

type ProtoMatcher added in v0.6.0

type ProtoMatcher struct {
	Expected proto.Message
}

func (*ProtoMatcher) FailureMessage added in v0.6.0

func (matcher *ProtoMatcher) FailureMessage(actual any) (message string)

func (*ProtoMatcher) Match added in v0.6.0

func (matcher *ProtoMatcher) Match(actual any) (success bool, err error)

func (*ProtoMatcher) NegatedFailureMessage added in v0.6.0

func (matcher *ProtoMatcher) NegatedFailureMessage(actual any) (message string)

type Session

type Session interface {
	G() (*gexec.Session, bool)
	Wait() error
}

func StartCmd

func StartCmd(cmd *exec.Cmd) (Session, error)

Jump to

Keyboard shortcuts

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