package packetAnalyzer

import (
	"testing"

	"github.com/google/gopacket"
	"github.com/google/gopacket/pcap"
)

func TestPacket(t *testing.T) {
	var Handle *pcap.Handle

	filename := "foo"
	maxNumPackets := 2
	ifLocalIPKnown := false
	localIP := "143.198.72.237"
	ch := make(chan gopacket.Packet)
	done := make(chan struct{})
	go PacketBreeze(ch, done, maxNumPackets, localIP, ifLocalIPKnown, filename)

	defer Handle.Close()

	packetSource := gopacket.NewPacketSource(Handle, Handle.LinkType())

loop:
	for packet := range packetSource.Packets() {
		select {
		case ch <- packet:
		case <-done:
			close(ch)
			close(done)
			break loop
		}

	}
}
