(ctx context.Context, t *testing.T, db database.Store, handlerFunc func(w http.ResponseWriter, r *http.Request), opts ...webpush.Option)
| 530 | } |
| 531 | |
| 532 | func setupPushTestWithOptions(ctx context.Context, t *testing.T, db database.Store, handlerFunc func(w http.ResponseWriter, r *http.Request), opts ...webpush.Option) (webpush.Dispatcher, database.Store, string) { |
| 533 | t.Helper() |
| 534 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug) |
| 535 | |
| 536 | server := httptest.NewServer(http.HandlerFunc(handlerFunc)) |
| 537 | t.Cleanup(server.Close) |
| 538 | |
| 539 | // Use an unrestricted HTTP client for tests. The default SSRF-safe |
| 540 | // client rejects loopback addresses, which blocks httptest.Server. |
| 541 | opts = append(opts, webpush.WithHTTPClient(http.DefaultClient)) |
| 542 | manager, err := webpush.New(ctx, &logger, db, "http://example.com", opts...) |
| 543 | require.NoError(t, err, "Failed to create webpush manager") |
| 544 | |
| 545 | return manager, db, server.URL |
| 546 | } |
| 547 | |
| 548 | func TestNoopWebpusher(t *testing.T) { |
| 549 | t.Parallel() |
no test coverage detected