yanic/respond/collector_test.go

39 lines
698 B
Go
Raw Normal View History

2016-03-19 14:07:44 +00:00
package respond
import (
"io/ioutil"
"testing"
"time"
2016-03-19 14:07:44 +00:00
"github.com/FreifunkBremen/yanic/runtime"
2016-03-19 14:07:44 +00:00
"github.com/stretchr/testify/assert"
)
func TestCollector(t *testing.T) {
nodes := runtime.NewNodes(&runtime.Config{})
collector := NewCollector(nil, nodes, []string{}, 10001)
collector.Start(time.Millisecond)
time.Sleep(time.Millisecond * 10)
collector.Close()
}
2016-03-19 14:07:44 +00:00
func TestParse(t *testing.T) {
assert := assert.New(t)
// read testdata
compressed, err := ioutil.ReadFile("testdata/nodeinfo.flated")
assert.Nil(err)
2016-10-03 17:55:37 +00:00
res := &Response{
2016-03-19 14:07:44 +00:00
Raw: compressed,
2016-10-03 17:55:37 +00:00
}
data, err := res.parse()
assert.NoError(err)
assert.NotNil(data)
2016-03-19 14:07:44 +00:00
assert.Equal("f81a67a5e9c1", data.NodeInfo.NodeID)
2016-03-19 14:07:44 +00:00
}