Skip to content

Commit

Permalink
settings: fix funky test
Browse files Browse the repository at this point in the history
This test was polluting the global Registry which was causing any
subsequent test to panic.

Release note: None
  • Loading branch information
andreimatei committed Sep 9, 2019
1 parent 9f20b5c commit 76d6324
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/settings/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 76d6324

Please sign in to comment.