Files
story/cmd/api/main_test.go
T

22 lines
520 B
Go
Raw Normal View History

2026-08-26 06:41:07 +08:00
package main
import (
"context"
"errors"
"testing"
)
func TestRunWiresAPIServiceAndPropagatesError(t *testing.T) {
want := errors.New("synthetic API failure")
ctx := context.WithValue(context.Background(), struct{}{}, "request-context")
err := run(ctx, func(gotContext context.Context, serviceName string) error {
if gotContext != ctx || serviceName != "api" {
t.Fatalf("context=%v service=%q", gotContext, serviceName)
}
return want
})
if !errors.Is(err, want) {
t.Fatalf("run error=%v", err)
}
}