cloudflare/cloudflared
Publicmirrored from https://github.com/cloudflare/cloudflaredAvailable
hello/hello_test.go
38lines · modecode
| 1 | package hello |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | func TestCreateTLSListenerHostAndPortSuccess(t *testing.T) { |
| 8 | listener, err := CreateTLSListener("localhost:1234") |
| 9 | if err != nil { |
| 10 | t.Fatal(err) |
| 11 | } |
| 12 | defer listener.Close() |
| 13 | if listener.Addr().String() == "" { |
| 14 | t.Fatal("Fail to find available port") |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | func TestCreateTLSListenerOnlyHostSuccess(t *testing.T) { |
| 19 | listener, err := CreateTLSListener("localhost:") |
| 20 | if err != nil { |
| 21 | t.Fatal(err) |
| 22 | } |
| 23 | defer listener.Close() |
| 24 | if listener.Addr().String() == "" { |
| 25 | t.Fatal("Fail to find available port") |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func TestCreateTLSListenerOnlyPortSuccess(t *testing.T) { |
| 30 | listener, err := CreateTLSListener(":8888") |
| 31 | if err != nil { |
| 32 | t.Fatal(err) |
| 33 | } |
| 34 | defer listener.Close() |
| 35 | if listener.Addr().String() == "" { |
| 36 | t.Fatal("Fail to find available port") |
| 37 | } |
| 38 | } |
| 39 | |