Allow FeatureGate values to be overridden in benchmarks.

This updates `SetFeatureGateDuringTest` to use the `testing.TB`
interface, which matches *testing.T and *testing.B.
pull/564/head
Jonathan Basseri 2018-12-13 18:44:39 -08:00
parent 94806e6a9a
commit 28a6a446a1
1 changed files with 3 additions and 3 deletions

View File

@ -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)
}
}
}