| 10 | ) |
| 11 | |
| 12 | func TestLoggingHandler(t *testing.T) { |
| 13 | rec := httptest.NewRecorder() |
| 14 | req := httptest.NewRequest("GET", "/test", nil) |
| 15 | |
| 16 | mux := http.NewServeMux() |
| 17 | mux.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) { |
| 18 | if RequestID(r) == "" { |
| 19 | t.Error("Request should have request id") |
| 20 | } |
| 21 | w.WriteHeader(201) |
| 22 | }) |
| 23 | Handler()(mux).ServeHTTP(rec, req) |
| 24 | |
| 25 | resp := rec.Result() |
| 26 | defer resp.Body.Close() |
| 27 | |
| 28 | if resp.StatusCode != 201 { |
| 29 | t.Error("expected 201 status code") |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func Test_isPrivate(t *testing.T) { |
| 34 | tests := []struct { |