| 927 | } |
| 928 | |
| 929 | func TestRenderStaticErrorPageNoStatus(t *testing.T) { |
| 930 | t.Parallel() |
| 931 | |
| 932 | d := site.ErrorPageData{ |
| 933 | HideStatus: true, |
| 934 | Status: http.StatusBadGateway, |
| 935 | Title: "Bad Gateway 1234", |
| 936 | Description: "shout out colin", |
| 937 | Actions: []site.Action{ |
| 938 | { |
| 939 | Text: "Retry", |
| 940 | }, |
| 941 | { |
| 942 | URL: "https://example.com", |
| 943 | Text: "Back to site", |
| 944 | }, |
| 945 | }, |
| 946 | } |
| 947 | |
| 948 | rw := httptest.NewRecorder() |
| 949 | r := httptest.NewRequest("GET", "/", nil) |
| 950 | site.RenderStaticErrorPage(rw, r, d) |
| 951 | |
| 952 | resp := rw.Result() |
| 953 | defer resp.Body.Close() |
| 954 | require.Equal(t, d.Status, resp.StatusCode) |
| 955 | require.Contains(t, resp.Header.Get("Content-Type"), "text/html") |
| 956 | |
| 957 | body, err := io.ReadAll(resp.Body) |
| 958 | require.NoError(t, err) |
| 959 | bodyStr := string(body) |
| 960 | require.NotContains(t, bodyStr, strconv.Itoa(d.Status)) |
| 961 | require.Contains(t, bodyStr, d.Title) |
| 962 | require.Contains(t, bodyStr, d.Description) |
| 963 | require.Contains(t, bodyStr, "Retry") |
| 964 | require.Contains(t, bodyStr, "https://example.com") |
| 965 | } |
| 966 | |
| 967 | func TestJustFilesSystem(t *testing.T) { |
| 968 | t.Parallel() |