probe/ping/service/connection/connection_test.go
2018-09-20 14:57:30 +09:00

90 lines
1.7 KiB
Go

package connection
import (
"net"
"reflect"
"testing"
omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta"
ounp "git.loafle.net/overflow/util-go/net/ping"
"git.loafle.net/overflow_scanner/probe/__test"
)
func TestPing(t *testing.T) {
targetHost := __test.Host(
"",
"99",
"00:25:b3:fa:ca:9b",
)
targetPort := __test.Port(
targetHost,
7,
)
type args struct {
service *omd.Service
pingOption ounp.Option
}
tests := []struct {
name string
args args
want ounp.Result
wantErr bool
}{
{
name: "192.168.1.99",
args: args{
service: __test.Service(
targetPort,
omm.MetaCryptoTypeEnumNONE,
"",
),
pingOption: &ounp.PingOption{
Count: 3,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Ping(tt.args.service, tt.args.pingOption)
if (err != nil) != tt.wantErr {
t.Errorf("Ping() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Ping() = %v, want %v", got, tt.want)
}
})
}
}
func Test_getConnection(t *testing.T) {
type args struct {
service *omd.Service
pingOption ounp.Option
}
tests := []struct {
name string
args args
want net.Conn
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getConnection(tt.args.service, tt.args.pingOption)
if (err != nil) != tt.wantErr {
t.Errorf("getConnection() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("getConnection() = %v, want %v", got, tt.want)
}
})
}
}