2016-03-12 13:32:55 +01:00
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2023-09-18 10:55:05 +02:00
|
|
|
"os"
|
2016-03-12 13:32:55 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestStatistics(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
obj := &Statistics{}
|
|
|
|
testfile("statistics.json", obj)
|
|
|
|
|
2017-01-20 22:27:44 +01:00
|
|
|
assert.Equal("f81a67a601ea", obj.NodeID)
|
2017-03-06 20:18:08 +01:00
|
|
|
assert.Equal("52:54:00:a9:f7:6e", obj.GatewayIPv4)
|
2016-03-12 13:32:55 +01:00
|
|
|
assert.Equal(float64(57861871176), obj.Traffic.Rx.Bytes)
|
|
|
|
assert.Equal(uint32(35), obj.Clients.Total)
|
|
|
|
assert.Equal(uint32(35), obj.Clients.Wifi)
|
|
|
|
assert.Equal(uint32(30), obj.Clients.Wifi24)
|
|
|
|
assert.Equal(uint32(8), obj.Clients.Wifi5)
|
2023-09-18 19:56:18 +02:00
|
|
|
assert.Equal(uint32(10), obj.Clients.OWE)
|
|
|
|
assert.Equal(uint32(5), obj.Clients.OWE24)
|
|
|
|
assert.Equal(uint32(6), obj.Clients.OWE5)
|
2016-03-12 13:32:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func testfile(name string, obj interface{}) {
|
2023-09-18 10:55:05 +02:00
|
|
|
file, err := os.ReadFile("testdata/" + name)
|
2016-03-12 13:32:55 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := json.Unmarshal(file, obj); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|