contexttest

package
v0.0.0-...-385f433 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 3

Documentation

Overview

Package contexttest builds a test context.Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context

func Context(tb testing.TB) context.Context

Context returns a Context that may be used in tests. Uses ptrace as the platform.Platform.

Note that some filesystems may require a minimal kernel for testing, which this test context does not provide. For such tests, see kernel/contexttest.

func RootContext

func RootContext(tb testing.TB) context.Context

RootContext returns a Context that may be used in tests that need root credentials. Uses ptrace as the platform.Platform.

func WithLimitSet

func WithLimitSet(ctx context.Context, l *limits.LimitSet) context.Context

WithLimitSet returns a copy of ctx carrying l.

Types

type TestContext

type TestContext struct {
	context.Context
	// contains filtered or unexported fields
}

TestContext represents a context with minimal functionality suitable for running tests.

func (*TestContext) RegisterValue

func (t *TestContext) RegisterValue(key, value any)

RegisterValue registers additional values with this test context. Useful for providing values from external packages that contexttest can't depend on.

func (*TestContext) Value

func (t *TestContext) Value(key any) any

Value implements context.Context.

Jump to

Keyboard shortcuts

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