freifunkmanager/runtime/node_test.go

37 lines
776 B
Go
Raw Normal View History

2017-05-07 03:37:30 +02:00
package runtime
import (
2018-06-30 01:45:51 +02:00
"net"
2017-05-07 03:37:30 +02:00
"testing"
"github.com/stretchr/testify/assert"
2018-06-30 01:45:51 +02:00
yanicData "github.com/FreifunkBremen/yanic/data"
2017-05-07 03:37:30 +02:00
yanicRuntime "github.com/FreifunkBremen/yanic/runtime"
)
func TestNode(t *testing.T) {
assert := assert.New(t)
2018-06-30 01:45:51 +02:00
node1 := &yanicRuntime.Node{
Address: &net.UDPAddr{IP: net.ParseIP("ff02::1")},
}
2017-05-07 03:37:30 +02:00
n1 := NewNode(node1)
assert.Nil(n1)
2018-06-30 01:45:51 +02:00
node1.Nodeinfo = &yanicData.NodeInfo{
Owner: &yanicData.Owner{Contact: "blub"},
Wireless: &yanicData.Wireless{},
Location: &yanicData.Location{Altitude: 13},
2017-05-07 03:37:30 +02:00
}
n1 = NewNode(node1)
assert.NotNil(n1)
assert.Equal(float64(13), n1.Location.Altitude)
n2 := NewNode(node1)
assert.True(n2.IsEqual(n1))
node1.Nodeinfo.Owner.Contact = "blub2"
n2.Update(node1)
assert.False(n2.IsEqual(n1))
}