From e7b31c8ebcff2fc183c6c3605c78e9620180ded9 Mon Sep 17 00:00:00 2001 From: xh3b4sd Date: Tue, 17 Oct 2023 00:53:15 +0200 Subject: [PATCH] allow Task.Cron and Task.Gate to be used together (#26) --- engine/create.go | 3 --- engine/engine_create_redis_test.go | 23 ++--------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/engine/create.go b/engine/create.go index fb3f038..a8a06cc 100644 --- a/engine/create.go +++ b/engine/create.go @@ -148,9 +148,6 @@ func (e *Engine) verCre(tas *task.Task) (*ticker.Ticker, error) { wai = true } - if tri && tas.Cron != nil { - return nil, tracer.Maskf(labelValueError, "Task.Gate must not contain reserved value [trigger] if Task.Cron is configured") - } if tri && wai { return nil, tracer.Maskf(labelValueError, "Task.Gate must not contain both of the reserved values [trigger waiting] together") } diff --git a/engine/engine_create_redis_test.go b/engine/engine_create_redis_test.go index 43e2c3e..8fa676f 100644 --- a/engine/engine_create_redis_test.go +++ b/engine/engine_create_redis_test.go @@ -288,25 +288,6 @@ func Test_Engine_Create_Cron(t *testing.T) { }, } - err = eon.Create(tas) - if !IsLabelValue(err) { - t.Fatal(err) - } - } - - { - tas := &task.Task{ - Cron: &task.Cron{ - task.Aevery: "hour", - }, - Meta: &task.Meta{ - "test.api.io/key": "bar", - }, - Gate: &task.Gate{ - "test.api.io/k-0": task.Waiting, - }, - } - err = eon.Create(tas) if err != nil { t.Fatal(err) @@ -342,8 +323,8 @@ func Test_Engine_Create_Cron(t *testing.T) { if lis[1].Cron.Get().Aevery() != "hour" { t.Fatal("expected", "hour", "got", lis[1].Cron.Get().Aevery()) } - if lis[1].Gate.Get("test.api.io/k-0") != task.Waiting { - t.Fatal("expected", task.Waiting, "got", lis[1].Gate.Get("test.api.io/k-0")) + if lis[1].Gate.Get("test.api.io/k-0") != task.Trigger { + t.Fatal("expected", task.Trigger, "got", lis[1].Gate.Get("test.api.io/k-0")) } }