package main

import (
	"net/http"
	"net/http/httptest"
	"testing"
)

func TestEndpointIsolation(t *testing.T) {
	admin := adminMux()
	public := http.NewServeMux()
	for _, tc := range []struct {
		h      http.Handler
		method string
		want   int
	}{
		{admin, "GET", 200}, {admin, "POST", 405}, {public, "GET", 404},
	} {
		w := httptest.NewRecorder()
		tc.h.ServeHTTP(w, httptest.NewRequest(tc.method, "/debug/pprof/heap", nil))
		if w.Code != tc.want {
			t.Fatalf("%s: got %d want %d", tc.method, w.Code, tc.want)
		}
		t.Logf("%s status=%d", tc.method, w.Code)
	}
}
