MCPcopy
hub / github.com/digitalocean/doctl / waitForLocalServer

Function waitForLocalServer

internal/kubernetes/sso/sso_test.go:180–201  ·  view source on GitHub ↗
(ctx context.Context, port uint16)

Source from the content-addressed store, hash-verified

178}
179
180func waitForLocalServer(ctx context.Context, port uint16) error {
181 const (
182 pollInterval = 25 * time.Millisecond
183 dialTimeout = 2 * time.Second
184 )
185 addr := fmt.Sprintf("127.0.0.1:%d", port)
186 ticker := time.NewTicker(pollInterval)
187 defer ticker.Stop()
188
189 for {
190 select {
191 case <-ctx.Done():
192 return fmt.Errorf("timeout : %w", ctx.Err())
193 case <-ticker.C:
194 conn, err := net.DialTimeout("tcp", addr, dialTimeout)
195 if err == nil {
196 conn.Close()
197 return nil
198 }
199 }
200 }
201}
202
203func TestGetIDToken(t *testing.T) {
204 const (

Callers 1

TestGetIDTokenFunction · 0.85

Calls 4

SprintfMethod · 0.80
ErrorfMethod · 0.80
CloseMethod · 0.80
StopMethod · 0.45

Tested by

no test coverage detected