2017-05-20 12:46:29 +00:00
|
|
|
package meshviewerFFRGB
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRegister(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
2018-01-07 20:00:56 +00:00
|
|
|
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
2017-05-20 12:46:29 +00:00
|
|
|
node := NewNode(nodes, &runtime.Node{
|
2019-01-24 01:56:13 +00:00
|
|
|
Nodeinfo: &data.Nodeinfo{
|
2019-01-15 18:04:10 +00:00
|
|
|
Owner: &data.Owner{
|
|
|
|
Contact: "whoami",
|
|
|
|
},
|
|
|
|
Network: data.Network{
|
|
|
|
Mac: "blub",
|
|
|
|
Addresses: []string{"fe80::1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NotNil(node)
|
|
|
|
assert.Len(node.Addresses, 1)
|
|
|
|
|
|
|
|
node = NewNode(nodes, &runtime.Node{
|
2019-01-24 01:56:13 +00:00
|
|
|
Nodeinfo: &data.Nodeinfo{
|
2017-11-03 13:05:52 +00:00
|
|
|
Owner: &data.Owner{
|
|
|
|
Contact: "whoami",
|
|
|
|
},
|
2017-05-20 12:46:29 +00:00
|
|
|
Network: data.Network{
|
|
|
|
Mac: "blub",
|
|
|
|
},
|
|
|
|
Location: &data.Location{
|
2017-11-23 12:01:39 +00:00
|
|
|
Longitude: 13.3,
|
2018-01-07 20:00:56 +00:00
|
|
|
Latitude: 8.7,
|
2017-05-20 12:46:29 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Statistics: &data.Statistics{
|
|
|
|
Memory: data.Memory{
|
|
|
|
Free: 13,
|
|
|
|
Total: 50,
|
|
|
|
},
|
|
|
|
Wireless: []*data.WirelessAirtime{
|
2018-01-13 15:40:23 +00:00
|
|
|
{
|
2017-05-20 12:46:29 +00:00
|
|
|
ChanUtil: 0.3,
|
|
|
|
Frequency: 2512,
|
|
|
|
},
|
2018-01-13 15:40:23 +00:00
|
|
|
{
|
2017-05-20 12:46:29 +00:00
|
|
|
ChanUtil: 0.4,
|
|
|
|
Frequency: 2612,
|
|
|
|
},
|
2018-01-13 15:40:23 +00:00
|
|
|
{
|
2017-05-20 12:46:29 +00:00
|
|
|
ChanUtil: 0.5,
|
|
|
|
Frequency: 5200,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NotNil(node)
|
2019-01-15 18:04:10 +00:00
|
|
|
assert.NotNil(node.Addresses)
|
2017-11-03 13:05:52 +00:00
|
|
|
assert.Equal("whoami", node.Owner)
|
2017-11-04 19:22:22 +00:00
|
|
|
assert.Equal("blub", node.MAC)
|
2017-11-23 12:01:39 +00:00
|
|
|
assert.Equal(13.3, node.Location.Longitude)
|
2017-05-20 12:46:29 +00:00
|
|
|
assert.Equal(8.7, node.Location.Latitude)
|
|
|
|
assert.Equal(0.74, *node.MemoryUsage)
|
|
|
|
}
|