forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wireless_test.go
52 lines (46 loc) · 1.21 KB
/
wireless_test.go
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
// +build linux
package wireless
import (
"testing"
"github.com/stretchr/testify/assert"
)
var testInput = []byte(`Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
wlan0: 0000 60. -50. -256 0 0 0 1525 0 0
wlan1: 0000 70. -39. -256 0 0 0 12096 191188 0`)
func TestLoadWirelessTable(t *testing.T) {
expectedMetrics := []*wirelessInterface{
{
Interface: "wlan0",
Status: int64(0000),
Link: int64(60),
Level: int64(-50),
Noise: int64(-256),
Nwid: int64(0),
Crypt: int64(0),
Frag: int64(0),
Retry: int64(1525),
Misc: int64(0),
Beacon: int64(0),
},
{
Interface: "wlan1",
Status: int64(0000),
Link: int64(70),
Level: int64(-39),
Noise: int64(-256),
Nwid: int64(0),
Crypt: int64(0),
Frag: int64(0),
Retry: int64(12096),
Misc: int64(191188),
Beacon: int64(0),
},
}
metrics, err := loadWirelessTable(testInput)
if err != nil {
t.Fatal(err)
}
as := assert.New(t)
as.Equal(metrics, expectedMetrics)
}