MCPcopy
hub / github.com/labstack/echo / TestEchoStaticRedirectIndex

Function TestEchoStaticRedirectIndex

echo_test.go:565–586  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

563}
564
565func TestEchoStaticRedirectIndex(t *testing.T) {
566 e := New()
567
568 // HandlerFunc
569 ri := e.Static("/static", "_fixture")
570 assert.Equal(t, http.MethodGet, ri.Method)
571 assert.Equal(t, "/static*", ri.Path)
572 assert.Equal(t, "GET:/static*", ri.Name)
573 assert.Equal(t, []string{"*"}, ri.Parameters)
574
575 ctx, cancel := stdContext.WithTimeout(stdContext.Background(), 200*time.Millisecond)
576 defer cancel()
577 addr, err := startOnRandomPort(ctx, e)
578 if err != nil {
579 assert.Fail(t, err.Error())
580 }
581
582 code, body, err := doGet(fmt.Sprintf("http://%v/static", addr))
583 assert.NoError(t, err)
584 assert.True(t, strings.HasPrefix(body, "<!doctype html>"))
585 assert.Equal(t, http.StatusOK, code)
586}
587
588func TestEchoFile(t *testing.T) {
589 var testCases = []struct {

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
startOnRandomPortFunction · 0.85
doGetFunction · 0.85
StaticMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…