diff --git a/models/node_test.go b/models/node_test.go new file mode 100644 index 0000000..098e0a5 --- /dev/null +++ b/models/node_test.go @@ -0,0 +1,31 @@ +package models + +import ( + "testing" + + "github.com/FreifunkBremen/respond-collector/data" + "github.com/stretchr/testify/assert" +) + +func TestToInflux(t *testing.T) { + assert := assert.New(t) + + node := Node{ + Statistics: &data.Statistics{ + NodeId: "foobar", + LoadAverage: 0.5, + }, + Nodeinfo: &data.NodeInfo{ + Owner: &data.Owner{ + Contact: "nobody", + }, + }, + Neighbours: &data.Neighbours{}, + } + + tags, fields := node.ToInflux() + + assert.Equal("foobar", tags.GetString("nodeid")) + assert.Equal("nobody", tags.GetString("owner")) + assert.Equal(0.5, fields["load"]) +}