Skip to content

Commit 015021a

Browse files
fix(throttler/demo): rename underscore flags to dash format, add manager tests (#20033)
Signed-off-by: ManthanNimodiya <manthannimodiya989898@gmail.com>
1 parent d3e0496 commit 015021a

2 files changed

Lines changed: 27 additions & 343 deletions

File tree

go/vt/throttler/demo/throttler_demo.go

Lines changed: 0 additions & 343 deletions
This file was deleted.

go/vt/throttler/manager_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,33 @@ func TestManager_UpdateConfiguration_ZeroValues(t *testing.T) {
209209
require.NoError(t, err)
210210
}
211211

212+
func TestManager_Throttlers(t *testing.T) {
213+
f := &managerTestFixture{}
214+
err := f.setUp()
215+
require.NoError(t, err)
216+
defer f.tearDown()
217+
218+
got := f.m.Throttlers()
219+
want := []string{"t1", "t2"}
220+
assert.Equal(t, want, got, "Throttlers() should return sorted names of all registered throttlers")
221+
}
222+
223+
func TestManager_Log(t *testing.T) {
224+
f := &managerTestFixture{}
225+
err := f.setUp()
226+
require.NoError(t, err)
227+
defer f.tearDown()
228+
229+
// log() on an existing throttler with no activity returns an empty (non-nil) slice.
230+
results, err := f.m.log("t1")
231+
require.NoError(t, err)
232+
assert.Empty(t, results, "freshly created throttler should have no log entries")
233+
234+
// log() on an unknown throttler should return an error.
235+
_, err = f.m.log("unknown")
236+
require.Error(t, err, "log() should return an error for an unregistered throttler")
237+
}
238+
212239
func checkConfig(m *managerImpl, throttlers []string, updatedThrottlers []string, targetLag int64, ignoreNSlowestReplicas int32) error {
213240
// Sort list of throttler names because they came from a randomized Go map.
214241
sort.Strings(updatedThrottlers)

0 commit comments

Comments
 (0)