Skip to content
Permalink
Browse files

Allow FeatureGate values to be overridden in benchmarks.

This updates `SetFeatureGateDuringTest` to use the `testing.TB`
interface, which matches *testing.T and *testing.B.
  • Loading branch information...
misterikkit committed Dec 14, 2018
1 parent 94806e6 commit 28a6a446a14d064d8a85c3e59b3c77f2127be35b
Showing with 3 additions and 3 deletions.
  1. +3 −3 staging/src/k8s.io/apiserver/pkg/util/feature/testing/feature_gate_testing.go
@@ -29,16 +29,16 @@ import (
// Example use:
//
// defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, true)()
func SetFeatureGateDuringTest(t *testing.T, gate feature.FeatureGate, f feature.Feature, value bool) func() {
func SetFeatureGateDuringTest(tb testing.TB, gate feature.FeatureGate, f feature.Feature, value bool) func() {
originalValue := gate.Enabled(f)

if err := gate.(feature.MutableFeatureGate).Set(fmt.Sprintf("%s=%v", f, value)); err != nil {
t.Errorf("error setting %s=%v: %v", f, value, err)
tb.Errorf("error setting %s=%v: %v", f, value, err)
}

return func() {
if err := gate.(feature.MutableFeatureGate).Set(fmt.Sprintf("%s=%v", f, originalValue)); err != nil {
t.Errorf("error restoring %s=%v: %v", f, originalValue, err)
tb.Errorf("error restoring %s=%v: %v", f, originalValue, err)
}
}
}

0 comments on commit 28a6a44

Please sign in to comment.
You can’t perform that action at this time.