From 497bd72f29adb2577f598781884da2608f7637ab Mon Sep 17 00:00:00 2001 From: husam-e <2340614+husam-e@users.noreply.github.com> Date: Mon, 30 Oct 2023 22:26:49 +0200 Subject: [PATCH] Update scheduler_test.go --- scheduler_test.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/scheduler_test.go b/scheduler_test.go index a15a87e..9edfbd8 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -82,8 +82,10 @@ func TestScheduler_Every_InvalidInterval(t *testing.T) { interval interface{} expectedError string }{ - {"zero", 0, ErrInvalidInterval.Error()}, - {"negative", -1, ErrInvalidInterval.Error()}, + {"zero int", 0, ErrInvalidInterval.Error()}, + {"negative int", -1, ErrInvalidInterval.Error()}, + {"negative time.Duration", -1 * time.Millisecond, ErrInvalidInterval.Error()}, + {"negative string duration", "-1ms", ErrInvalidInterval.Error()}, {"invalid string duration", "bad", "time: invalid duration \"bad\""}, } @@ -93,7 +95,7 @@ func TestScheduler_Every_InvalidInterval(t *testing.T) { t.Run(tc.description, func(t *testing.T) { _, err := s.Every(tc.interval).Do(func() {}) require.Error(t, err) - assert.EqualError(t, err, tc.expectedError) + assert.ErrorContains(t, err, tc.expectedError) }) } } @@ -145,12 +147,6 @@ func TestScheduler_Every(t *testing.T) { } s.Stop() assert.Equal(t, 6, counter) - - _, err = s.Every(-1 * time.Millisecond).Do(func() { - // do nothing - }) - - require.Contains(t, err.Error(), ErrInvalidInterval.Error()) }) t.Run("int", func(t *testing.T) { @@ -198,12 +194,6 @@ func TestScheduler_Every(t *testing.T) { } s.Stop() assert.Equal(t, 2, counter) - - _, err = s.Every("-1ms").Do(func() { - // do nothing - }) - - require.Contains(t, err.Error(), ErrInvalidInterval.Error()) }) }