2017-04-10 16:54:12 +00:00
|
|
|
package meshviewer
|
2016-12-15 10:10:09 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2017-03-03 15:19:35 +00:00
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
2017-04-10 16:54:12 +00:00
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
2016-12-15 10:10:09 +00:00
|
|
|
)
|
|
|
|
|
2017-01-20 13:38:13 +00:00
|
|
|
func TestNodesV1(t *testing.T) {
|
2017-04-10 16:54:12 +00:00
|
|
|
nodes := GetNodesV1(createTestNodes())
|
2016-12-15 10:10:09 +00:00
|
|
|
|
|
|
|
assert := assert.New(t)
|
2017-03-06 08:52:39 +00:00
|
|
|
assert.Len(nodes.List, 2)
|
2017-01-20 13:38:13 +00:00
|
|
|
}
|
|
|
|
func TestNodesV2(t *testing.T) {
|
2017-04-10 16:54:12 +00:00
|
|
|
nodes := GetNodesV2(createTestNodes())
|
2017-01-20 13:38:13 +00:00
|
|
|
|
|
|
|
assert := assert.New(t)
|
2017-03-06 08:52:39 +00:00
|
|
|
assert.Len(nodes.List, 2)
|
2016-12-15 10:10:09 +00:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:54:12 +00:00
|
|
|
func createTestNodes() *runtime.Nodes {
|
|
|
|
nodes := runtime.NewNodes(&runtime.Config{})
|
2016-12-15 10:10:09 +00:00
|
|
|
|
|
|
|
nodeData := &data.ResponseData{
|
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Clients: data.Clients{
|
|
|
|
Total: 23,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
NodeInfo: &data.NodeInfo{
|
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "TP-Link 841",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
nodeData.NodeInfo.Software.Firmware.Release = "2016.1.6+entenhausen1"
|
|
|
|
nodes.Update("abcdef012345", nodeData)
|
|
|
|
|
|
|
|
nodes.Update("112233445566", &data.ResponseData{
|
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Clients: data.Clients{
|
|
|
|
Total: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
NodeInfo: &data.NodeInfo{
|
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "TP-Link 841",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
nodes.Update("0xdeadbeef0x", &data.ResponseData{
|
|
|
|
NodeInfo: &data.NodeInfo{
|
|
|
|
VPN: true,
|
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "Xeon Multi-Core",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return nodes
|
|
|
|
}
|