File: queue_test.go

package info (click to toggle)
bettercap 2.33.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,668 kB
  • sloc: sh: 154; makefile: 76; python: 52; ansic: 9
file content (65 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package packets

import (
	"net"
	"reflect"
	"testing"
)

func TestQueueActivity(t *testing.T) {
	i := net.IP{}
	h := net.HardwareAddr{}
	a := Activity{
		IP:  i,
		MAC: h,
	}
	var units = []struct {
		got interface{}
		exp interface{}
	}{
		{a.IP, i},
		{a.MAC, h},
		{a.Source, false},
	}
	for _, u := range units {
		if !reflect.DeepEqual(u.exp, u.got) {
			t.Fatalf("expected '%v', got '%v'", u.exp, u.got)
		}
	}
}

func TestQueueTraffic(t *testing.T) {
	tr := Traffic{}
	var units = []struct {
		got interface{}
		exp interface{}
	}{
		{tr.Sent, uint64(0)},
		{tr.Received, uint64(0)},
	}
	for _, u := range units {
		if !reflect.DeepEqual(u.exp, u.got) {
			t.Fatalf("expected '%v', got '%v'", u.exp, u.got)
		}
	}
}

func TestQueueStats(t *testing.T) {
	s := Stats{}
	var units = []struct {
		got interface{}
		exp interface{}
	}{
		{s.Sent, uint64(0)},
		{s.Received, uint64(0)},
		{s.PktReceived, uint64(0)},
		{s.Errors, uint64(0)},
	}
	for _, u := range units {
		if !reflect.DeepEqual(u.exp, u.got) {
			t.Fatalf("expected '%v', got '%v'", u.exp, u.got)
		}
	}
}

// TODO: add tests for the rest of queue.go