MCPcopy Index your code
hub / github.com/coder/coder / TestRenderStaticErrorPage

Function TestRenderStaticErrorPage

site/site_test.go:892–927  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

890}
891
892func TestRenderStaticErrorPage(t *testing.T) {
893 t.Parallel()
894
895 d := site.ErrorPageData{
896 Status: http.StatusBadGateway,
897 Title: "Bad Gateway 1234",
898 Description: "shout out colin",
899 Actions: []site.Action{
900 {
901 Text: "Retry",
902 },
903 {
904 URL: "https://example.com",
905 Text: "Back to site",
906 },
907 },
908 }
909
910 rw := httptest.NewRecorder()
911 r := httptest.NewRequest("GET", "/", nil)
912 site.RenderStaticErrorPage(rw, r, d)
913
914 resp := rw.Result()
915 defer resp.Body.Close()
916 require.Equal(t, d.Status, resp.StatusCode)
917 require.Contains(t, resp.Header.Get("Content-Type"), "text/html")
918
919 body, err := io.ReadAll(resp.Body)
920 require.NoError(t, err)
921 bodyStr := string(body)
922 require.Contains(t, bodyStr, strconv.Itoa(d.Status))
923 require.Contains(t, bodyStr, d.Title)
924 require.Contains(t, bodyStr, d.Description)
925 require.Contains(t, bodyStr, "Retry")
926 require.Contains(t, bodyStr, "https://example.com")
927}
928
929func TestRenderStaticErrorPageNoStatus(t *testing.T) {
930 t.Parallel()

Callers

nothing calls this directly

Calls 7

RenderStaticErrorPageFunction · 0.92
CloseMethod · 0.65
GetMethod · 0.65
ResultMethod · 0.45
EqualMethod · 0.45
ContainsMethod · 0.45
ReadAllMethod · 0.45

Tested by

no test coverage detected