Increase test coverage

This commit is contained in:
Julian Kornberger 2016-11-20 19:24:34 +01:00
parent 223e97bfaf
commit 79e8be48ec
1 changed files with 31 additions and 0 deletions

31
models/node_test.go Normal file
View File

@ -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"])
}