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

Function TestStartConfig_WithHideBanner

server_test.go:482–541  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

480}
481
482func TestStartConfig_WithHideBanner(t *testing.T) {
483 var testCases = []struct {
484 name string
485 hideBanner bool
486 }{
487 {
488 name: "hide banner on startup",
489 hideBanner: true,
490 },
491 {
492 name: "show banner on startup",
493 hideBanner: false,
494 },
495 }
496 for _, tc := range testCases {
497 t.Run(tc.name, func(t *testing.T) {
498 e := New()
499
500 buf := new(bytes.Buffer)
501 e.Logger = slog.New(slog.NewTextHandler(buf, nil))
502
503 e.GET("/ok", func(c *Context) error {
504 return c.String(http.StatusOK, "OK")
505 })
506
507 addrChan := make(chan string)
508 errCh := make(chan error)
509
510 ctx, shutdown := stdContext.WithTimeout(stdContext.Background(), 200*time.Millisecond)
511 defer shutdown()
512
513 go func() {
514 _, err := waitForServerStart(addrChan, errCh)
515 errCh <- err
516 shutdown()
517 }()
518
519 s := &StartConfig{
520 Address: ":0",
521 HideBanner: tc.hideBanner,
522 GracefulTimeout: 100 * time.Millisecond,
523 ListenerAddrFunc: func(addr net.Addr) {
524 addrChan <- addr.String()
525 },
526 }
527
528 if err := s.Start(ctx, e); err != http.ErrServerClosed {
529 assert.NoError(t, err)
530 }
531 assert.NoError(t, <-errCh)
532
533 contains := strings.Contains(buf.String(), "High performance, minimalist Go web framework")
534 if tc.hideBanner {
535 assert.False(t, contains)
536 } else {
537 assert.True(t, contains)
538 }
539 })

Callers

nothing calls this directly

Calls 5

StartMethod · 0.95
NewFunction · 0.85
waitForServerStartFunction · 0.85
GETMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…