(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestDebugger(t *testing.T) { |
| 19 | mux := http.NewServeMux() |
| 20 | |
| 21 | dbg1 := Debugger(mux) |
| 22 | if dbg1 == nil { |
| 23 | t.Fatal("didn't get a debugger from mux") |
| 24 | } |
| 25 | |
| 26 | dbg2 := Debugger(mux) |
| 27 | if dbg2 != dbg1 { |
| 28 | t.Fatal("Debugger returned different debuggers for the same mux") |
| 29 | } |
| 30 | |
| 31 | t.Run("cpu_pprof", func(t *testing.T) { |
| 32 | if testing.Short() { |
| 33 | t.Skip("skipping second long test") |
| 34 | } |
| 35 | switch runtime.GOOS { |
| 36 | case "linux", "darwin": |
| 37 | default: |
| 38 | t.Skipf("skipping test on %v", runtime.GOOS) |
| 39 | } |
| 40 | req := httptest.NewRequest("GET", "/debug/pprof/profile?seconds=1", nil) |
| 41 | req.RemoteAddr = "100.101.102.103:1234" |
| 42 | rec := httptest.NewRecorder() |
| 43 | mux.ServeHTTP(rec, req) |
| 44 | res := rec.Result() |
| 45 | if res.StatusCode != 200 { |
| 46 | t.Errorf("unexpected %v", res.Status) |
| 47 | } |
| 48 | }) |
| 49 | } |
| 50 | |
| 51 | func get(m http.Handler, path, srcIP string) (int, string) { |
| 52 | req := httptest.NewRequest("GET", path, nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…