MCPcopy
hub / github.com/rs/cors / TestOptionsSuccessStatusCodeDefault

Function TestOptionsSuccessStatusCodeDefault

cors_test.go:744–767  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

742}
743
744func TestOptionsSuccessStatusCodeDefault(t *testing.T) {
745 s := New(Options{
746 // Intentionally left blank.
747 })
748
749 req, _ := http.NewRequest("OPTIONS", "http://example.com/foo", nil)
750 req.Header.Add("Access-Control-Request-Method", "GET")
751
752 t.Run("Handler", func(t *testing.T) {
753 res := httptest.NewRecorder()
754 s.Handler(testHandler).ServeHTTP(res, req)
755 assertResponse(t, res, http.StatusNoContent)
756 })
757 t.Run("HandlerFunc", func(t *testing.T) {
758 res := httptest.NewRecorder()
759 s.HandlerFunc(res, req)
760 assertResponse(t, res, http.StatusNoContent)
761 })
762 t.Run("Negroni", func(t *testing.T) {
763 res := httptest.NewRecorder()
764 s.ServeHTTP(res, req, testHandler)
765 assertResponse(t, res, http.StatusNoContent)
766 })
767}
768
769func TestOptionsSuccessStatusCodeOverride(t *testing.T) {
770 s := New(Options{

Callers

nothing calls this directly

Calls 5

assertResponseFunction · 0.85
ServeHTTPMethod · 0.80
HandlerMethod · 0.80
HandlerFuncMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…