MCPcopy Create free account
hub / github.com/Vespa314/cflow / waitForServerStart

Method waitForServerStart

test/server/server.go:75–100  ·  view source on GitHub ↗
(errChan <-chan error)

Source from the content-addressed store, hash-verified

73}
74
75func (s *TestingServer) waitForServerStart(errChan <-chan error) error {
76 ticker := time.NewTicker(100 * time.Millisecond)
77 defer ticker.Stop()
78
79 for {
80 select {
81 case <-ticker.C:
82 if s == nil {
83 continue
84 }
85 e := s.server.GetEcho()
86 if e == nil {
87 continue
88 }
89 addr := e.ListenerAddr()
90 if addr != nil && strings.Contains(addr.String(), ":") {
91 return nil // was started
92 }
93 case err := <-errChan:
94 if err == http.ErrServerClosed {
95 return nil
96 }
97 return err
98 }
99 }
100}
101
102func (s *TestingServer) request(method, uri string, body io.Reader, params, header map[string]string) (io.ReadCloser, error) {
103 fullURL := fmt.Sprintf("http://localhost:%d%s", s.profile.Port, uri)

Callers 1

NewTestingServerFunction · 0.95

Calls 3

StopMethod · 0.80
GetEchoMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected