From a7479d5a196919422fef547b0a6113e267c402a8 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Mon, 21 Mar 2016 12:26:08 +0100 Subject: [PATCH] Add test for nodes.Update() --- models/nodes_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/models/nodes_test.go b/models/nodes_test.go index 51b54e8..50006e2 100644 --- a/models/nodes_test.go +++ b/models/nodes_test.go @@ -5,6 +5,7 @@ import ( "os" "testing" + "github.com/FreifunkBremen/respond-collector/data" "github.com/stretchr/testify/assert" ) @@ -23,3 +24,18 @@ func TestLoadAndSave(t *testing.T) { assert.Equal(1, len(nodes.List)) } + +func TestUpdateNodes(t *testing.T) { + assert := assert.New(t) + nodes := &Nodes{List: make(map[string]*Node)} + assert.Equal(0, len(nodes.List)) + + res := &data.ResponseData{ + Neighbours: &data.Neighbours{}, + Statistics: &data.Statistics{}, + NodeInfo: &data.NodeInfo{}, + } + nodes.Update("abcdef012345", res) + + assert.Equal(1, len(nodes.List)) +}