cloudflared-mirror/cmd/cloudflare-warp/hello_test.go

36 lines
701 B
Go
Raw Normal View History

2017-10-16 11:44:03 +00:00
package main
import (
"testing"
)
2018-02-20 21:13:56 +00:00
func TestCreateListenerHostAndPortSuccess(t *testing.T) {
listener, err := createListener("localhost:1234")
if err != nil {
t.Fatal(err)
}
if listener.Addr().String() == "" {
t.Fatal("Fail to find available port")
2017-10-16 11:44:03 +00:00
}
}
2018-02-20 21:13:56 +00:00
func TestCreateListenerOnlyHostSuccess(t *testing.T) {
listener, err := createListener("localhost:")
2017-10-16 11:44:03 +00:00
if err != nil {
2018-02-20 21:13:56 +00:00
t.Fatal(err)
}
if listener.Addr().String() == "" {
2017-10-16 11:44:03 +00:00
t.Fatal("Fail to find available port")
}
2018-02-20 21:13:56 +00:00
}
func TestCreateListenerOnlyPortSuccess(t *testing.T) {
listener, err := createListener(":8888")
if err != nil {
t.Fatal(err)
}
2017-10-16 11:44:03 +00:00
if listener.Addr().String() == "" {
t.Fatal("Fail to find available port")
}
}