This commit is contained in:
crusader 2018-08-30 03:37:40 +09:00
parent 42c3ad9ab4
commit f15521f202
4 changed files with 63 additions and 30 deletions

View File

@ -6,10 +6,10 @@ import (
omd "git.loafle.net/overflow/model/discovery" omd "git.loafle.net/overflow/model/discovery"
omu "git.loafle.net/overflow/model/util" omu "git.loafle.net/overflow/model/util"
"git.loafle.net/overflow_scanner/probe/discovery/protocol/mdns"
"git.loafle.net/overflow_scanner/probe/discovery/protocol/upnp"
"git.loafle.net/overflow_scanner/probe/discovery/session" "git.loafle.net/overflow_scanner/probe/discovery/session"
"git.loafle.net/overflow_scanner/probe/discovery/types" "git.loafle.net/overflow_scanner/probe/discovery/types"
"git.loafle.net/overflow_scanner/probe/internal/protocol/mdns"
"git.loafle.net/overflow_scanner/probe/internal/protocol/upnp"
) )
type Discoverer interface { type Discoverer interface {

View File

@ -0,0 +1,19 @@
package discovery
import "git.loafle.net/overflow_scanner/probe/discovery/types"
func MockDiscoveryRequest(requesterID string, requestType types.DiscoveryRequestType, params ...interface{}) *mockDiscoveryRequest {
m := &mockDiscoveryRequest{}
m.requesterID = requesterID
m.requestType = requestType
m.params = params
return m
}
type mockDiscoveryRequest struct {
ofDiscoveryRequest
}
func (dr *mockDiscoveryRequest) SendMessage(messageType types.DiscoveryMessageType, data interface{}, err error) {
}

View File

@ -6,14 +6,19 @@ import (
omd "git.loafle.net/overflow/model/discovery" omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta" omm "git.loafle.net/overflow/model/meta"
"git.loafle.net/overflow_scanner/probe/discovery"
"git.loafle.net/overflow_scanner/probe/discovery/session" "git.loafle.net/overflow_scanner/probe/discovery/session"
"git.loafle.net/overflow_scanner/probe/discovery/types"
"github.com/grandcat/zeroconf" "github.com/grandcat/zeroconf"
) )
func TestScan(t *testing.T) { func TestScan(t *testing.T) {
s := session.MockDiscoverySession() s := session.MockDiscoverySession()
s.InitWithDiscoverHost( s.InitWithRequest(
nil, discovery.MockDiscoveryRequest(
"testRequester",
types.DiscoveryRequestTypeHost,
[]interface{}{
&omd.Zone{ &omd.Zone{
Network: "192.168.1.0/24", Network: "192.168.1.0/24",
Iface: "enp3s0", Iface: "enp3s0",
@ -26,6 +31,8 @@ func TestScan(t *testing.T) {
FirstScanRange: "192.168.1.1", FirstScanRange: "192.168.1.1",
LastScanRange: "192.168.1.254", LastScanRange: "192.168.1.254",
}, },
},
),
) )
type args struct { type args struct {

View File

@ -5,13 +5,18 @@ import (
omd "git.loafle.net/overflow/model/discovery" omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta" omm "git.loafle.net/overflow/model/meta"
"git.loafle.net/overflow_scanner/probe/discovery"
"git.loafle.net/overflow_scanner/probe/discovery/session" "git.loafle.net/overflow_scanner/probe/discovery/session"
"git.loafle.net/overflow_scanner/probe/discovery/types"
) )
func TestScan(t *testing.T) { func TestScan(t *testing.T) {
s := session.MockDiscoverySession() s := session.MockDiscoverySession()
s.InitWithDiscoverHost( s.InitWithRequest(
nil, discovery.MockDiscoveryRequest(
"testRequester",
types.DiscoveryRequestTypeHost,
[]interface{}{
&omd.Zone{ &omd.Zone{
Network: "192.168.1.0/24", Network: "192.168.1.0/24",
Iface: "enp3s0", Iface: "enp3s0",
@ -24,6 +29,8 @@ func TestScan(t *testing.T) {
FirstScanRange: "192.168.1.1", FirstScanRange: "192.168.1.1",
LastScanRange: "192.168.1.254", LastScanRange: "192.168.1.254",
}, },
},
),
) )
type args struct { type args struct {