2017-04-10 18:54:12 +02:00
|
|
|
package meshviewer
|
2016-12-15 11:10:09 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2017-03-03 16:19:35 +01:00
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
2017-04-10 18:54:12 +02:00
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
2016-12-15 11:10:09 +01:00
|
|
|
)
|
|
|
|
|
2017-01-20 14:38:13 +01:00
|
|
|
func TestNodesV1(t *testing.T) {
|
2017-04-16 15:12:23 +02:00
|
|
|
nodes := BuildNodesV1(createTestNodes()).(*NodesV1)
|
2016-12-15 11:10:09 +01:00
|
|
|
|
|
|
|
assert := assert.New(t)
|
2017-03-06 09:52:39 +01:00
|
|
|
assert.Len(nodes.List, 2)
|
2017-01-20 14:38:13 +01:00
|
|
|
}
|
|
|
|
func TestNodesV2(t *testing.T) {
|
2017-04-16 15:12:23 +02:00
|
|
|
nodes := BuildNodesV2(createTestNodes()).(*NodesV2)
|
2017-01-20 14:38:13 +01:00
|
|
|
|
|
|
|
assert := assert.New(t)
|
2017-03-06 09:52:39 +01:00
|
|
|
assert.Len(nodes.List, 2)
|
2016-12-15 11:10:09 +01:00
|
|
|
}
|
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
func createTestNodes() *runtime.Nodes {
|
2018-01-07 21:00:56 +01:00
|
|
|
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
2016-12-15 11:10:09 +01:00
|
|
|
|
2017-05-20 14:46:29 +02:00
|
|
|
nodeData := &runtime.Node{
|
2016-12-15 11:10:09 +01:00
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Clients: data.Clients{
|
|
|
|
Total: 23,
|
|
|
|
},
|
|
|
|
},
|
2019-01-24 02:56:13 +01:00
|
|
|
Nodeinfo: &data.Nodeinfo{
|
2017-05-20 14:46:29 +02:00
|
|
|
NodeID: "abcdef012345",
|
2016-12-15 11:10:09 +01:00
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "TP-Link 841",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2017-05-20 14:46:29 +02:00
|
|
|
nodeData.Nodeinfo.Software.Firmware.Release = "2016.1.6+entenhausen1"
|
|
|
|
nodes.AddNode(nodeData)
|
2016-12-15 11:10:09 +01:00
|
|
|
|
2017-05-20 14:46:29 +02:00
|
|
|
nodes.AddNode(&runtime.Node{
|
2016-12-15 11:10:09 +01:00
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Clients: data.Clients{
|
2017-05-20 14:46:29 +02:00
|
|
|
Wifi24: 2,
|
|
|
|
Wifi5: 3,
|
|
|
|
},
|
|
|
|
Memory: data.Memory{
|
|
|
|
Total: 32,
|
|
|
|
Free: 8,
|
2016-12-15 11:10:09 +01:00
|
|
|
},
|
|
|
|
},
|
2019-01-24 02:56:13 +01:00
|
|
|
Nodeinfo: &data.Nodeinfo{
|
2017-05-20 14:46:29 +02:00
|
|
|
NodeID: "112233445566",
|
2016-12-15 11:10:09 +01:00
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "TP-Link 841",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2017-05-20 14:46:29 +02:00
|
|
|
nodes.AddNode(&runtime.Node{
|
2019-01-24 02:56:13 +01:00
|
|
|
Nodeinfo: &data.Nodeinfo{
|
2017-05-20 14:46:29 +02:00
|
|
|
NodeID: "0xdeadbeef0x",
|
|
|
|
VPN: true,
|
2016-12-15 11:10:09 +01:00
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "Xeon Multi-Core",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return nodes
|
|
|
|
}
|