component-basek8s.io/component-base/featuregate/testing Index | Files

package testing

import "k8s.io/component-base/featuregate/testing"

Index

Functions

func SetFeatureGateDuringTest

func SetFeatureGateDuringTest(tb TB, gate featuregate.FeatureGate, f featuregate.Feature, value bool)

SetFeatureGateDuringTest sets the specified gate to the specified value for duration of the test. Fails when it detects second call to the same flag or is unable to set or restore feature flag.

WARNING: Can leak set variable when called in test calling t.Parallel(), however second attempt to set the same feature flag will cause fatal.

Example use:

featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, true)

func SetFeatureGateEmulationVersionDuringTest

func SetFeatureGateEmulationVersionDuringTest(tb TB, gate featuregate.FeatureGate, ver *version.Version)

featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.31"))

Types

type TB

type TB interface {
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Helper()
	Name() string
}

Source Files

feature_gate.go

Version
v0.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
1 hour ago

Tools for package owners.