2018-05-01 23:45:06 +00:00
|
|
|
package hello
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCreateTLSListenerHostAndPortSuccess(t *testing.T) {
|
|
|
|
listener, err := CreateTLSListener("localhost:1234")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-07-25 14:07:27 +00:00
|
|
|
defer listener.Close()
|
2018-05-01 23:45:06 +00:00
|
|
|
if listener.Addr().String() == "" {
|
|
|
|
t.Fatal("Fail to find available port")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateTLSListenerOnlyHostSuccess(t *testing.T) {
|
|
|
|
listener, err := CreateTLSListener("localhost:")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-07-25 14:07:27 +00:00
|
|
|
defer listener.Close()
|
2018-05-01 23:45:06 +00:00
|
|
|
if listener.Addr().String() == "" {
|
|
|
|
t.Fatal("Fail to find available port")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateTLSListenerOnlyPortSuccess(t *testing.T) {
|
2021-02-08 21:31:51 +00:00
|
|
|
listener, err := CreateTLSListener("localhost:8888")
|
2018-05-01 23:45:06 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-07-25 14:07:27 +00:00
|
|
|
defer listener.Close()
|
2018-05-01 23:45:06 +00:00
|
|
|
if listener.Addr().String() == "" {
|
|
|
|
t.Fatal("Fail to find available port")
|
|
|
|
}
|
|
|
|
}
|