From 76d63249c32e72e103032ae46ffceb8cf4c67aef Mon Sep 17 00:00:00 2001 From: Andrei Matei Date: Mon, 9 Sep 2019 18:42:22 -0400 Subject: [PATCH] settings: fix funky test This test was polluting the global Registry which was causing any subsequent test to panic. Release note: None --- pkg/settings/settings_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/settings/settings_test.go b/pkg/settings/settings_test.go index 4f1966c00116..4f9f431cdf17 100644 --- a/pkg/settings/settings_test.go +++ b/pkg/settings/settings_test.go @@ -643,12 +643,21 @@ func TestOnChangeWithMaxSettings(t *testing.T) { } func TestMaxSettingsPanics(t *testing.T) { + var origRegistry = make(map[string]settings.Setting) + for k, v := range settings.Registry { + origRegistry[k] = v + } + defer func() { + settings.Registry = origRegistry + }() + // Register too many settings which will cause a panic which is caught and converted to an error. _, err := batchRegisterSettings(t, t.Name(), maxSettings-len(settings.Keys())) expectedErr := "too many settings; increase maxSettings" if err == nil || err.Error() != expectedErr { t.Errorf("expected error %v, but got %v", expectedErr, err) } + } func batchRegisterSettings(t *testing.T, keyPrefix string, count int) (name string, err error) {