From be8677e1c3359f8f7b4040b3dfc039774c82c873 Mon Sep 17 00:00:00 2001 From: Jan Franchini Date: Sat, 11 Nov 2023 11:28:27 +0000 Subject: [PATCH] test(cron): should return error if running out of IDs --- cron_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cron_test.go b/cron_test.go index 47ba49c..7ac1fa4 100644 --- a/cron_test.go +++ b/cron_test.go @@ -785,6 +785,20 @@ func TestMultiThreadedStartAndStop(t *testing.T) { cron.Stop() } +func TestRunningOutOfIDs(t *testing.T) { + cron := New() + cron.next = ID(^uint(0)) + + _, err := cron.Add("* * * * *", func() {}) + if err != nil { + t.Error("non-nil error") + } + _, err = cron.Add("* * * * *", func() {}) + if err == nil { + t.Error("expected error, got nil") + } +} + func wait(wg *sync.WaitGroup) chan bool { ch := make(chan bool) go func() {