add common unit test
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user