Skip to content

Commit

Permalink
allow Task.Cron and Task.Gate to be used together (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
xh3b4sd committed Oct 16, 2023
1 parent d4b2bc8 commit e7b31c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
3 changes: 0 additions & 3 deletions engine/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
23 changes: 2 additions & 21 deletions engine/engine_create_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
}
}

Expand Down

0 comments on commit e7b31c8

Please sign in to comment.