package handler_test import ( "io" "net/http" "net/http/httptest" "testing" "git.netflux.io/rob/netflux-homepage/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestHandler(t *testing.T) { const ( matrixHostname = "foo.example.com:443" matrixBaseURL = "https://foo.example.com" ) testCases := []struct { name string method string path string wantContentType string wantStatusCode int wantBody string }{ { name: "GET /.well-known/matrix/server", method: http.MethodGet, path: "/.well-known/matrix/server", wantContentType: "application/json", wantStatusCode: http.StatusOK, wantBody: `{"m.server": "foo.example.com:443"}`, }, { name: "GET /.well-known/matrix/client", method: http.MethodGet, path: "/.well-known/matrix/client", wantContentType: "application/json", wantStatusCode: http.StatusOK, wantBody: `{"m.homeserver": {"base_url": "https://foo.example.com"}}`, }, { name: "GET /robots.txt", method: http.MethodGet, path: "/robots.txt", wantContentType: "text/plain", wantStatusCode: http.StatusOK, wantBody: "Allow: /", }, { name: "GET /test.html", method: http.MethodGet, path: "/test.html", wantContentType: "text/html; charset=utf-8", wantStatusCode: http.StatusOK, wantBody: "\n
\n