MCPcopy Index your code
hub / github.com/coder/coder / setupPushTestWithOptions

Function setupPushTestWithOptions

coderd/webpush/webpush_test.go:532–546  ·  view source on GitHub ↗
(ctx context.Context, t *testing.T, db database.Store, handlerFunc func(w http.ResponseWriter, r *http.Request), opts ...webpush.Option)

Source from the content-addressed store, hash-verified

530}
531
532func 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
548func TestNoopWebpusher(t *testing.T) {
549 t.Parallel()

Callers 2

TestPushFunction · 0.85
setupPushTestFunction · 0.85

Calls 4

WithHTTPClientFunction · 0.92
NewFunction · 0.92
HelperMethod · 0.65
CleanupMethod · 0.65

Tested by

no test coverage detected