2019-11-13 11:37:54 +00:00
|
|
|
package raw
|
2019-11-13 11:14:15 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTransform(t *testing.T) {
|
|
|
|
nodes := transform(createTestNodes())
|
|
|
|
|
|
|
|
assert := assert.New(t)
|
|
|
|
assert.Len(nodes.List, 3)
|
|
|
|
}
|
|
|
|
|
|
|
|
func createTestNodes() *runtime.Nodes {
|
|
|
|
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
|
|
|
|
|
|
|
nodeData := &runtime.Node{
|
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Clients: data.Clients{
|
|
|
|
Total: 23,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Nodeinfo: &data.Nodeinfo{
|
|
|
|
NodeID: "abcdef012345",
|
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "TP-Link 841",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
nodeData.Nodeinfo.Software.Firmware.Release = "2016.1.6+entenhausen1"
|
|
|
|
nodes.AddNode(nodeData)
|
|
|
|
|
|
|
|
nodes.AddNode(&runtime.Node{
|
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Clients: data.Clients{
|
|
|
|
Total: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Nodeinfo: &data.Nodeinfo{
|
|
|
|
NodeID: "112233445566",
|
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "TP-Link 841",
|
|
|
|
},
|
|
|
|
Location: &data.Location{
|
|
|
|
Latitude: 23,
|
|
|
|
Longitude: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
nodes.AddNode(&runtime.Node{
|
|
|
|
Nodeinfo: &data.Nodeinfo{
|
|
|
|
NodeID: "0xdeadbeef0x",
|
|
|
|
VPN: true,
|
|
|
|
Hardware: data.Hardware{
|
|
|
|
Model: "Xeon Multi-Core",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return nodes
|
|
|
|
}
|