Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab3d7b62a9 |
@@ -125,7 +125,8 @@ error away. That is how `log/slog` works, and simplelog cannot change it.
|
||||
To find out whether a record was delivered, build a `slog.Record` and pass
|
||||
it to the handler yourself, for example
|
||||
`slog.Default().Handler().Handle(ctx, record)`, then check the error it
|
||||
returns.
|
||||
returns. A record passed to `Handle` directly gets the wrong file and
|
||||
line in console output.
|
||||
|
||||
## Entrypoints
|
||||
|
||||
|
||||
@@ -82,6 +82,38 @@ func TestMultiplexHandlerDeliversPastFailingHandler(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// When more than one handler fails, the caller gets every failure, not
|
||||
// only the first.
|
||||
func TestMultiplexHandlerReturnsEveryFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(
|
||||
func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
},
|
||||
))
|
||||
defer server.Close()
|
||||
|
||||
webhook, err := NewWebhookHandler(server.URL)
|
||||
if err != nil {
|
||||
t.Fatalf("NewWebhookHandler: %v", err)
|
||||
}
|
||||
|
||||
handler := &MultiplexHandler{handlers: []ExtendedHandler{
|
||||
&JSONHandler{out: failingWriter{}},
|
||||
webhook,
|
||||
}}
|
||||
|
||||
err = handler.Handle(context.Background(), errorTestRecord())
|
||||
if !errors.Is(err, errSinkFailed) {
|
||||
t.Fatalf("Handle returned %v, want the JSON handler's error", err)
|
||||
}
|
||||
|
||||
if !errors.Is(err, errWebhookStatus) {
|
||||
t.Fatalf("Handle returned %v, want the webhook's error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebhookHandlerReturnsErrorOnServerError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user