testleak

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoSecretInBytes

func AssertNoSecretInBytes(t testing.TB, data []byte, secrets ...string)

AssertNoSecretInBytes asserts that none of the provided non-empty secrets appear anywhere in the given byte slice. If a secret is leaked, the test fails without exposing the raw secret value in the failure message.

func AssertNoSecretInError

func AssertNoSecretInError(t testing.TB, err error, secrets ...string)

AssertNoSecretInError asserts that if err is non-nil, none of the secrets appear in err.Error().

func AssertNoSecretInLogs

func AssertNoSecretInLogs(t testing.TB, l *BufferLogger, secrets ...string)

AssertNoSecretInLogs asserts that none of the provided secrets appear in the captured logs.

func AssertNoSecretInString

func AssertNoSecretInString(t testing.TB, text string, secrets ...string)

AssertNoSecretInString asserts that none of the provided non-empty secrets appear anywhere in the given text string.

func AssertNoSecretInYAML

func AssertNoSecretInYAML(t testing.TB, yamlData []byte, secrets ...string)

AssertNoSecretInYAML asserts that raw serialized YAML bytes do not contain any plaintext secret values.

func AssertSecretPresentInBytes

func AssertSecretPresentInBytes(t testing.TB, data []byte, secret string)

AssertSecretPresentInBytes asserts that the expected non-empty secret is present in the byte slice.

func AssertSecretPresentInString

func AssertSecretPresentInString(t testing.TB, text string, secret string)

AssertSecretPresentInString asserts that the expected non-empty secret is present in text.

Types

type BufferLogger

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

BufferLogger implements logger.DebugLogger to capture runtime logs safely in memory.

func NewBufferLogger

func NewBufferLogger() *BufferLogger

NewBufferLogger creates a thread-safe in-memory buffer logger.

func (*BufferLogger) Bytes

func (l *BufferLogger) Bytes() []byte

Bytes returns a thread-safe snapshot copy of captured log bytes.

func (*BufferLogger) Debug

func (l *BufferLogger) Debug(msg string, args ...any)

func (*BufferLogger) Debugf

func (l *BufferLogger) Debugf(format string, args ...any)

func (*BufferLogger) String

func (l *BufferLogger) String() string

String returns a thread-safe snapshot string of captured logs.

Jump to

Keyboard shortcuts

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