add common unit test

This commit is contained in:
Jay
2020-01-14 15:00:01 +00:00
parent 9b9edf08d8
commit ed4ee637ab
4 changed files with 55 additions and 4 deletions
+31 -4
View File
@@ -1,8 +1,11 @@
package common
import "testing"
import (
"testing"
)
func TestCheckRemoteSSH(t *testing.T) {
type args struct {
host string
port int
@@ -14,10 +17,10 @@ func TestCheckRemoteSSH(t *testing.T) {
want error
}{
{
name: "test check localhost ssh port",
name: "test check google web port",
args: args{
host: "localhost",
port: 22,
host: "google.com",
port: 80,
timeout: 5,
},
want: nil,
@@ -31,3 +34,27 @@ func TestCheckRemoteSSH(t *testing.T) {
})
}
}
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)
}
})
}
}