(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestRequestURL(t *testing.T) { |
| 29 | m := RequestURL() |
| 30 | |
| 31 | t.Run("HTTP", func(t *testing.T) { |
| 32 | a := assertions.New(t) |
| 33 | |
| 34 | r := httptest.NewRequest(http.MethodGet, "/path", nil) |
| 35 | |
| 36 | rec := httptest.NewRecorder() |
| 37 | m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 38 | a.So(r.URL.String(), should.Equal, "http://example.com/path") |
| 39 | })).ServeHTTP(rec, r) |
| 40 | }) |
| 41 | |
| 42 | t.Run("HTTPS", func(t *testing.T) { |
| 43 | a := assertions.New(t) |
| 44 | |
| 45 | r := httptest.NewRequest(http.MethodGet, "/path", nil) |
| 46 | r.TLS = &tls.ConnectionState{ |
| 47 | Version: tls.VersionTLS12, |
| 48 | HandshakeComplete: true, |
| 49 | ServerName: r.Host, |
| 50 | } |
| 51 | |
| 52 | rec := httptest.NewRecorder() |
| 53 | m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 54 | a.So(r.URL.String(), should.Equal, "https://example.com/path") |
| 55 | })).ServeHTTP(rec, r) |
| 56 | }) |
| 57 | } |
nothing calls this directly
no test coverage detected