22 lines
529 B
Go
22 lines
529 B
Go
package main
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"errors"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestRunWiresWorkerServiceAndPropagatesError(t *testing.T) {
|
||
|
|
want := errors.New("synthetic worker failure")
|
||
|
|
ctx := context.WithValue(context.Background(), struct{}{}, "request-context")
|
||
|
|
err := run(ctx, func(gotContext context.Context, serviceName string) error {
|
||
|
|
if gotContext != ctx || serviceName != "worker" {
|
||
|
|
t.Fatalf("context=%v service=%q", gotContext, serviceName)
|
||
|
|
}
|
||
|
|
return want
|
||
|
|
})
|
||
|
|
if !errors.Is(err, want) {
|
||
|
|
t.Fatalf("run error=%v", err)
|
||
|
|
}
|
||
|
|
}
|