(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func TestDialTLSTimeout(t *testing.T) { |
| 129 | apns.TLSDialTimeout = 10 * time.Millisecond |
| 130 | crt, _ := certificate.FromP12File("certificate/_fixtures/certificate-valid.p12", "") |
| 131 | client := apns.NewClient(crt) |
| 132 | dialTLS := client.HTTPClient.Transport.(*http2.Transport).DialTLS |
| 133 | listener, err := net.Listen("tcp", "127.0.0.1:0") |
| 134 | if err != nil { |
| 135 | t.Fatal(err) |
| 136 | } |
| 137 | address := listener.Addr().String() |
| 138 | defer listener.Close() |
| 139 | var e error |
| 140 | if _, e = dialTLS("tcp", address, nil); e == nil { |
| 141 | t.Fatal("Dial completed successfully") |
| 142 | } |
| 143 | // Go 1.7.x and later will return a context deadline exceeded error |
| 144 | // Previous versions will return a time out |
| 145 | if !strings.Contains(e.Error(), "timed out") && !errors.Is(e, context.DeadlineExceeded) { |
| 146 | t.Errorf("Unexpected error: %s", e) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // Functional Tests |
| 151 |
nothing calls this directly
no test coverage detected