2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-07-30 02:03:47 +08:00

feat: Add an option to specify headers

This commit is contained in:
kayoch1n
2026-03-17 12:29:58 +08:00
parent d704b68a42
commit 5c391f3ffb
4 changed files with 110 additions and 1 deletions

View File

@@ -3526,6 +3526,7 @@ func TestParseOption(t *testing.T) {
{ProcessAt(oneHourFromNow).String(), ProcessAtOpt, oneHourFromNow},
{`ProcessIn(10m)`, ProcessInOpt, 10 * time.Minute},
{`Retention(24h)`, RetentionOpt, 24 * time.Hour},
{`Header(["email", "hello@example.com"])`, HeaderOpt, [2]string{"email", "hello@example.com"}},
}
for _, tc := range tests {
@@ -3573,6 +3574,14 @@ func TestParseOption(t *testing.T) {
if cmp.Equal(gotVal, tc.wantVal.(time.Time)) {
t.Fatalf("got value %v, want %v", gotVal, tc.wantVal)
}
case HeaderOpt:
gotVal, ok := got.Value().([2]string)
if !ok {
t.Fatal("returned Option with non array value")
}
if gotVal != tc.wantVal.([2]string) {
t.Fatalf("got value %v, want %v", gotVal, tc.wantVal)
}
default:
t.Fatalf("returned Option with unexpected type: %v", got.Type())
}