MCPcopy
hub / github.com/gorilla/websocket / TestTracingDialWithContext

Function TestTracingDialWithContext

client_server_test.go:846–903  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

844}
845
846func TestTracingDialWithContext(t *testing.T) {
847
848 var headersWrote, requestWrote, getConn, gotConn, connectDone, gotFirstResponseByte bool
849 trace := &httptrace.ClientTrace{
850 WroteHeaders: func() {
851 headersWrote = true
852 },
853 WroteRequest: func(httptrace.WroteRequestInfo) {
854 requestWrote = true
855 },
856 GetConn: func(hostPort string) {
857 getConn = true
858 },
859 GotConn: func(info httptrace.GotConnInfo) {
860 gotConn = true
861 },
862 ConnectDone: func(network, addr string, err error) {
863 connectDone = true
864 },
865 GotFirstResponseByte: func() {
866 gotFirstResponseByte = true
867 },
868 }
869 ctx := httptrace.WithClientTrace(context.Background(), trace)
870
871 s := newTLSServer(t)
872 defer s.Close()
873
874 d := cstDialer
875 d.TLSClientConfig = &tls.Config{RootCAs: rootCAs(t, s.Server)}
876
877 ws, _, err := d.DialContext(ctx, s.URL, nil)
878 if err != nil {
879 t.Fatalf("Dial: %v", err)
880 }
881
882 if !headersWrote {
883 t.Fatal("Headers was not written")
884 }
885 if !requestWrote {
886 t.Fatal("Request was not written")
887 }
888 if !getConn {
889 t.Fatal("getConn was not called")
890 }
891 if !gotConn {
892 t.Fatal("gotConn was not called")
893 }
894 if !connectDone {
895 t.Fatal("connectDone was not called")
896 }
897 if !gotFirstResponseByte {
898 t.Fatal("GotFirstResponseByte was not called")
899 }
900
901 defer ws.Close()
902 sendRecv(t, ws)
903}

Callers

nothing calls this directly

Calls 5

newTLSServerFunction · 0.85
rootCAsFunction · 0.85
sendRecvFunction · 0.85
DialContextMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected