2018-09-17 11:05:12 +00:00
|
|
|
package ping
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestPing(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
destination string
|
|
|
|
options *PingOptions
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
2018-09-17 11:10:14 +00:00
|
|
|
want *PingResult
|
2018-09-17 11:05:12 +00:00
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "192.168.1.1",
|
|
|
|
args: args{
|
|
|
|
destination: "192.168.1.1",
|
|
|
|
options: &PingOptions{
|
|
|
|
Retry: 4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
got, err := Ping(tt.args.destination, tt.args.options)
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("Ping() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if got != tt.want {
|
|
|
|
t.Errorf("Ping() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|