mirror of
https://github.com/hibiken/asynq.git
synced 2025-09-19 05:17:30 +08:00
Update Option interface
- Added `String()`, `Type()`, and `Value()` methods to the interface to aid with debugging and error handling.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
package asynq
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -77,37 +76,3 @@ func TestScheduler(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringifyOptions(t *testing.T) {
|
||||
now := time.Now()
|
||||
oneHourFromNow := now.Add(1 * time.Hour)
|
||||
twoHoursFromNow := now.Add(2 * time.Hour)
|
||||
tests := []struct {
|
||||
opts []Option
|
||||
want string
|
||||
}{
|
||||
{
|
||||
opts: []Option{MaxRetry(10)},
|
||||
want: "MaxRetry(10)",
|
||||
},
|
||||
{
|
||||
opts: []Option{Queue("custom"), Timeout(1 * time.Minute)},
|
||||
want: `Queue("custom"), Timeout(1m0s)`,
|
||||
},
|
||||
{
|
||||
opts: []Option{ProcessAt(oneHourFromNow), Deadline(twoHoursFromNow)},
|
||||
want: fmt.Sprintf("ProcessAt(%v), Deadline(%v)", oneHourFromNow, twoHoursFromNow),
|
||||
},
|
||||
{
|
||||
opts: []Option{ProcessIn(30 * time.Minute), Unique(1 * time.Hour)},
|
||||
want: "ProcessIn(30m0s), Unique(1h0m0s)",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
got := stringifyOptions(tc.opts)
|
||||
if got != tc.want {
|
||||
t.Errorf("got %v, want %v", got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user