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

Function TestRenderStaticErrorPageNoStatus

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

Source from the content-addressed store, hash-verified

927}
928
929func 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
967func TestJustFilesSystem(t *testing.T) {
968 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