tcp-proxy/pkg/common/common_test.go

61 lines
1.0 KiB
Go
Raw Normal View History

2020-01-13 10:05:18 +00:00
package common
2020-01-14 15:00:01 +00:00
import (
"testing"
)
2020-01-13 10:05:18 +00:00
func TestCheckRemoteSSH(t *testing.T) {
2020-01-14 15:00:01 +00:00
2020-01-13 10:05:18 +00:00
type args struct {
host string
port int
timeout int
}
tests := []struct {
name string
args args
2020-01-14 09:58:05 +00:00
want error
2020-01-13 10:05:18 +00:00
}{
{
2020-01-14 15:00:01 +00:00
name: "test check google web port",
2020-01-13 10:05:18 +00:00
args: args{
2020-01-14 15:00:01 +00:00
host: "google.com",
port: 80,
2020-01-13 10:05:18 +00:00
timeout: 5,
},
2020-01-14 09:58:05 +00:00
want: nil,
2020-01-13 10:05:18 +00:00
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
2020-01-14 09:58:05 +00:00
if got := CheckRemoteTCP(tt.args.host, tt.args.port, tt.args.timeout); got != tt.want {
2020-01-13 10:05:18 +00:00
t.Errorf("CheckRemoteSSH() = %v, want %v", got, tt.want)
}
})
}
}
2020-01-14 15:00:01 +00:00
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)
}
})
}
}