(ctx context.Context, port uint16)
| 178 | } |
| 179 | |
| 180 | func 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 | |
| 203 | func TestGetIDToken(t *testing.T) { |
| 204 | const ( |
no test coverage detected