probe/ping/service/matcher/matcher_test.go
crusader 419c5cb6ac ing
2018-09-18 01:25:56 +09:00

112 lines
2.4 KiB
Go

package matcher
import (
"net"
"reflect"
"testing"
omd "git.loafle.net/overflow/model/discovery"
osm "git.loafle.net/overflow/service_matcher-go"
ounp "git.loafle.net/overflow/util-go/net/ping"
)
func TestPing(t *testing.T) {
type args struct {
service *omd.Service
pingOption ounp.Option
}
tests := []struct {
name string
args args
want ounp.Result
wantErr bool
}{
// TODO: Add test cases.
}
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_processPrepacket(t *testing.T) {
type args struct {
service *omd.Service
pingOption ounp.Option
matchCtx *osm.MatchCtx
_matcher osm.Matcher
}
tests := []struct {
name string
args args
want ounp.Result
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := processPrepacket(tt.args.service, tt.args.pingOption, tt.args.matchCtx, tt.args._matcher); !reflect.DeepEqual(got, tt.want) {
t.Errorf("processPrepacket() = %v, want %v", got, tt.want)
}
})
}
}
func Test_processPostpacket(t *testing.T) {
type args struct {
service *omd.Service
pingOption ounp.Option
matchCtx *osm.MatchCtx
_matcher osm.Matcher
}
tests := []struct {
name string
args args
want ounp.Result
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := processPostpacket(tt.args.service, tt.args.pingOption, tt.args.matchCtx, tt.args._matcher); !reflect.DeepEqual(got, tt.want) {
t.Errorf("processPostpacket() = %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)
}
})
}
}