tcp-proxy/pkg/common/common_test.go
2020-01-14 15:00:01 +00:00

61 lines
1.0 KiB
Go

package common
import (
"testing"
)
func TestCheckRemoteSSH(t *testing.T) {
type args struct {
host string
port int
timeout int
}
tests := []struct {
name string
args args
want error
}{
{
name: "test check google web port",
args: args{
host: "google.com",
port: 80,
timeout: 5,
},
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CheckRemoteTCP(tt.args.host, tt.args.port, tt.args.timeout); got != tt.want {
t.Errorf("CheckRemoteSSH() = %v, want %v", got, tt.want)
}
})
}
}
func TestCheckDomain(t *testing.T) {
type args struct {
name string
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "test domain check",
args: args{name: "trj.tw"},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := CheckDomain(tt.args.name); (err != nil) != tt.wantErr {
t.Errorf("CheckDomain() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}