Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b73e1c59be |
@@ -125,8 +125,7 @@ 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
|
To find out whether a record was delivered, build a `slog.Record` and pass
|
||||||
it to the handler yourself, for example
|
it to the handler yourself, for example
|
||||||
`slog.Default().Handler().Handle(ctx, record)`, then check the error it
|
`slog.Default().Handler().Handle(ctx, record)`, then check the error it
|
||||||
returns. A record passed to `Handle` directly gets the wrong file and
|
returns.
|
||||||
line in console output.
|
|
||||||
|
|
||||||
## Entrypoints
|
## Entrypoints
|
||||||
|
|
||||||
|
|||||||
@@ -82,38 +82,6 @@ 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) {
|
func TestWebhookHandlerReturnsErrorOnServerError(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user