From 79e8be48ec8537bc53f33a89ba0b949e53451be2 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Sun, 20 Nov 2016 19:24:34 +0100 Subject: [PATCH] Increase test coverage --- models/node_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 models/node_test.go 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"]) +}