Increase test coverage
This commit is contained in:
parent
223e97bfaf
commit
79e8be48ec
31
models/node_test.go
Normal file
31
models/node_test.go
Normal 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"])
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user