yanic/meshviewer/nodes_test.go

67 lines
1.2 KiB
Go
Raw Normal View History

package meshviewer
import (
"testing"
"github.com/stretchr/testify/assert"
2017-03-03 15:19:35 +00:00
"github.com/FreifunkBremen/yanic/data"
"github.com/FreifunkBremen/yanic/runtime"
)
func TestNodesV1(t *testing.T) {
nodes := GetNodesV1(createTestNodes())
assert := assert.New(t)
assert.Len(nodes.List, 2)
}
func TestNodesV2(t *testing.T) {
nodes := GetNodesV2(createTestNodes())
assert := assert.New(t)
assert.Len(nodes.List, 2)
}
func createTestNodes() *runtime.Nodes {
nodes := runtime.NewNodes(&runtime.Config{})
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
}