34 lines
817 B
Go
34 lines
817 B
Go
package netcheck
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"vpnclient/internal/config"
|
|
)
|
|
|
|
func TestFriendlyDialError(t *testing.T) {
|
|
err := &netError{s: "dial tcp 1.2.3.4:22514: connectex: No connection could be made because the target machine actively refused it."}
|
|
got := friendlyDialError(err, true)
|
|
if !strings.Contains(got, "UDP") {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|
|
|
|
type netError struct{ s string }
|
|
|
|
func (e *netError) Error() string { return e.s }
|
|
func (e *netError) Timeout() bool { return false }
|
|
func (e *netError) Temporary() bool { return false }
|
|
|
|
func TestPingProfileEmpty(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
defer cancel()
|
|
r := PingProfile(ctx, "x", config.ProtocolHysteria2, "")
|
|
if r.OK || r.Error == "" {
|
|
t.Fatalf("%+v", r)
|
|
}
|
|
}
|