MCPcopy Index your code
hub / github.com/labstack/echo / TestEcho_Start

Function TestEcho_Start

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

Source from the content-addressed store, hash-verified

1239}
1240
1241func TestEcho_Start(t *testing.T) {
1242 e := New()
1243 e.GET("/", func(c *Context) error {
1244 return c.String(http.StatusTeapot, "OK")
1245 })
1246 rndPort, err := net.Listen("tcp", ":0")
1247 if err != nil {
1248 t.Fatal(err)
1249 }
1250 defer rndPort.Close()
1251 errChan := make(chan error, 1)
1252 go func() {
1253 errChan <- e.Start(rndPort.Addr().String())
1254 }()
1255
1256 select {
1257 case <-time.After(250 * time.Millisecond):
1258 t.Fatal("start did not error out")
1259 case err := <-errChan:
1260 expectContains := "bind: address already in use"
1261 if runtime.GOOS == "windows" {
1262 expectContains = "bind: Only one usage of each socket address"
1263 }
1264 assert.Contains(t, err.Error(), expectContains)
1265 }
1266}
1267
1268func request(method, path string, e *Echo) (int, string) {
1269 req := httptest.NewRequest(method, path, nil)

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
AfterMethod · 0.80
GETMethod · 0.45
StringMethod · 0.45
CloseMethod · 0.45
StartMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…