testutils

package
v1.4.1-prerelease32 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNilChance is the default probability of generating nil values
	DefaultNilChance = 0.3
	// DefaultIterations is the default number of fuzzing iterations
	DefaultIterations = 100
	// MaxSafeTimestampSeconds is the maximum safe Unix timestamp (year 2100)
	MaxSafeTimestampSeconds = 4102444800
	// NanosecondsPerSecond is the number of nanoseconds in a second
	NanosecondsPerSecond = 1000000000
	// MaxDurationSeconds is the maximum duration in seconds (24 hours)
	MaxDurationSeconds = 86400
)

Variables

This section is empty.

Functions

func CrossClusterTaskFailedCauseFuzzer added in v1.4.1

func CrossClusterTaskFailedCauseFuzzer(e *types.CrossClusterTaskFailedCause, c fuzz.Continue)

func CrossClusterTaskTypeFuzzer added in v1.4.1

func CrossClusterTaskTypeFuzzer(e *types.CrossClusterTaskType, c fuzz.Continue)

func DLQTypeFuzzer added in v1.4.1

func DLQTypeFuzzer(e *types.DLQType, c fuzz.Continue)

func DomainOperationFuzzer added in v1.4.1

func DomainOperationFuzzer(e *types.DomainOperation, c fuzz.Continue)

func DomainStatusFuzzer added in v1.4.1

func DomainStatusFuzzer(e *types.DomainStatus, c fuzz.Continue)

func EncodingTypeFuzzer added in v1.4.1

func EncodingTypeFuzzer(e *types.EncodingType, c fuzz.Continue)

func EnsureFuzzCoverage

func EnsureFuzzCoverage(t *testing.T, expected []string, cb func(t *testing.T, f *fuzz.Fuzzer) string)

func GetTaskFailedCauseFuzzer added in v1.4.1

func GetTaskFailedCauseFuzzer(e *types.GetTaskFailedCause, c fuzz.Continue)

func IsolationGroupStateFuzzer added in v1.4.1

func IsolationGroupStateFuzzer(e *types.IsolationGroupState, c fuzz.Continue)

func ReplicationTaskTypeFuzzer added in v1.4.1

func ReplicationTaskTypeFuzzer(e *types.ReplicationTaskType, c fuzz.Continue)

func RunMapperFuzzTest added in v1.4.1

func RunMapperFuzzTest[TInternal any, TExternal any](
	t *testing.T,
	fromFunc func(TInternal) TExternal,
	toFunc func(TExternal) TInternal,
	options ...FuzzOption,
)

RunMapperFuzzTest runs a fuzz test for a mapper pair (From/To functions). It generates random values, converts them through the mapper pair, and verifies the round-trip preserves the original value.

Example usage:

func TestActivityTypeFuzz(t *testing.T) {
    RunMapperFuzzTest(t, FromActivityType, ToActivityType)
}

func TaskTypeFuzzer added in v1.4.1

func TaskTypeFuzzer(e *int32, c fuzz.Continue)

func WorkflowStateFuzzer added in v1.4.1

func WorkflowStateFuzzer(e *int32, c fuzz.Continue)

Types

type FuzzOption added in v1.4.1

type FuzzOption func(*FuzzOptions)

FuzzOption is a functional option for configuring FuzzOptions

func WithCommonEnumFuzzers added in v1.4.1

func WithCommonEnumFuzzers() FuzzOption

WithCommonEnumFuzzers adds fuzzers for common Cadence enum types to ensure only valid enum values are generated

func WithCustomFuncs added in v1.4.1

func WithCustomFuncs(funcs ...interface{}) FuzzOption

WithCustomFuncs adds custom fuzzer functions for specific types

func WithDefaultFuzzers added in v1.4.1

func WithDefaultFuzzers() FuzzOption

WithDefaultFuzzers applies the standard set of fuzzers for time and common enums. This is applied automatically by RunMapperFuzzTest unless overridden.

func WithExcludedFields added in v1.4.1

func WithExcludedFields(fields ...string) FuzzOption

WithExcludedFields specifies field names to exclude from comparison

func WithIterations added in v1.4.1

func WithIterations(iterations int) FuzzOption

WithIterations sets the number of fuzzing iterations

func WithNilChance added in v1.4.1

func WithNilChance(chance float64) FuzzOption

WithNilChance sets the probability of generating nil values

func WithTimeFuzzers added in v1.4.1

func WithTimeFuzzers() FuzzOption

WithTimeFuzzers adds custom fuzzers for time.Time and time.Duration to ensure safe timestamp bounds and proper UTC normalization

type FuzzOptions added in v1.4.1

type FuzzOptions struct {
	// CustomFuncs are custom fuzzer functions to apply for specific types
	CustomFuncs []interface{}
	// ExcludedFields are field names to exclude from comparison (set to zero value)
	ExcludedFields []string
	// NilChance is the probability of setting pointer/slice fields to nil (default DefaultNilChance)
	NilChance float64
	// Iterations is the number of fuzzing iterations to run (default DefaultIterations)
	Iterations int
}

FuzzOptions configures the behavior of mapper fuzz tests

Jump to

Keyboard shortcuts

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