MCPcopy Create free account
hub / github.com/facebook/time / TestClientConnectFullHandshake

Function TestClientConnectFullHandshake

ntrip/client_test.go:289–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

287}
288
289func TestClientConnectFullHandshake(t *testing.T) {
290 listener, err := net.Listen("tcp", "127.0.0.1:0")
291 require.NoError(t, err)
292 defer listener.Close()
293
294 c := NewClient(Config{
295 Caster: listener.Addr().String(),
296 Mountpoint: "/TEST",
297 Password: "testpass",
298 })
299
300 go func() {
301 conn, err := listener.Accept()
302 if err != nil {
303 return
304 }
305 defer conn.Close()
306
307 reader := bufio.NewReader(conn)
308 // Read SOURCE request.
309 for {
310 line, err := reader.ReadString('\n')
311 if err != nil {
312 return
313 }
314 if strings.TrimSpace(line) == "" {
315 break
316 }
317 }
318 // Send success response.
319 _, _ = conn.Write([]byte("ICY 200 OK\r\n"))
320
321 // Keep connection alive for the test.
322 buf := make([]byte, 1)
323 _, _ = conn.Read(buf)
324 }()
325
326 ctx := context.Background()
327 err = c.Connect(ctx)
328 require.NoError(t, err)
329 defer c.Close()
330
331 _, err = c.Write([]byte("test data"))
332 require.NoError(t, err)
333}
334
335func TestProxyConfigInvalidCertPath(t *testing.T) {
336 c := NewClient(Config{

Callers

nothing calls this directly

Calls 7

WriteMethod · 0.95
ConnectMethod · 0.95
CloseMethod · 0.95
NewClientFunction · 0.70
CloseMethod · 0.65
ReadMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…