Skip to content

Commit

Permalink
[BUGFIX] meshviewer-ffrgb export empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Jan 15, 2019
1 parent 6579d52 commit 32b9f43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion output/meshviewer-ffrgb/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ func NewNode(nodes *runtime.Nodes, n *runtime.Node) *Node {
Lastseen: n.Lastseen,
IsOnline: n.Online,
IsGateway: n.IsGateway(),
Addresses: []string{},
}

if nodeinfo := n.Nodeinfo; nodeinfo != nil {
node.NodeID = nodeinfo.NodeID
node.MAC = nodeinfo.Network.Mac
node.Addresses = nodeinfo.Network.Addresses
node.SiteCode = nodeinfo.System.SiteCode
node.DomainCode = nodeinfo.System.DomainCode
node.Hostname = nodeinfo.Hostname
if addresses := nodeinfo.Network.Addresses; addresses != nil {
node.Addresses = nodeinfo.Network.Addresses
}
if owner := nodeinfo.Owner; owner != nil {
node.Owner = owner.Contact
}
Expand Down
15 changes: 15 additions & 0 deletions output/meshviewer-ffrgb/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ func TestRegister(t *testing.T) {
assert := assert.New(t)
nodes := runtime.NewNodes(&runtime.NodesConfig{})
node := NewNode(nodes, &runtime.Node{
Nodeinfo: &data.NodeInfo{
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{
Nodeinfo: &data.NodeInfo{
Owner: &data.Owner{
Contact: "whoami",
Expand Down Expand Up @@ -46,6 +60,7 @@ func TestRegister(t *testing.T) {
},
})
assert.NotNil(node)
assert.NotNil(node.Addresses)
assert.Equal("whoami", node.Owner)
assert.Equal("blub", node.MAC)
assert.Equal(13.3, node.Location.Longitude)
Expand Down

0 comments on commit 32b9f43

Please sign in to comment.