MCPcopy Index your code
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestWaitCommandFlags

Function TestWaitCommandFlags

cmd/wait_test.go:24–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestWaitCommandFlags(t *testing.T) {
25 ln, err := net.Listen("tcp", "localhost:0")
26 if err != nil {
27 t.Fatal(err)
28 }
29 defer ln.Close()
30 host, port, err := net.SplitHostPort(ln.Addr().String())
31 if err != nil {
32 t.Fatal(err)
33 }
34 go func() {
35 conn, err := ln.Accept()
36 if err != nil {
37 return
38 }
39 defer conn.Close()
40 // Use a read deadline to produce read error
41 conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
42 // Read client request first.
43 io.ReadAll(conn)
44 // Write a generic 200 response back.
45 conn.Write([]byte("HTTP/1.1 200 OK\r\n\r\n"))
46 }()
47
48 _, err = invokeProxyCommand([]string{
49 "wait",
50 "--http-address", host,
51 "--http-port", port,
52 "--max=1s",
53 })
54 if err != nil {
55 t.Fatal(err)
56 }
57}
58
59func TestWaitCommandFails(t *testing.T) {
60 _, err := invokeProxyCommand([]string{

Callers

nothing calls this directly

Calls 5

invokeProxyCommandFunction · 0.85
StringMethod · 0.80
AddrMethod · 0.80
AcceptMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected