File: peerdb_test.go

package info (click to toggle)
docker.io 20.10.24%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 60,824 kB
  • sloc: sh: 5,621; makefile: 593; ansic: 179; python: 162; asm: 7
file content (30 lines) | stat: -rw-r--r-- 796 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package overlay

import (
	"net"
	"testing"

	_ "github.com/docker/libnetwork/testutils"
)

func TestPeerMarshal(t *testing.T) {
	_, ipNet, _ := net.ParseCIDR("192.168.0.1/24")
	p := &peerEntry{eid: "eid",
		isLocal:    true,
		peerIPMask: ipNet.Mask,
		vtep:       ipNet.IP}
	entryDB := p.MarshalDB()
	x := entryDB.UnMarshalDB()
	if x.eid != p.eid {
		t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.eid, p.eid)
	}
	if x.isLocal != p.isLocal {
		t.Fatalf("Incorrect Unmarshalling for isLocal: %v != %v", x.isLocal, p.isLocal)
	}
	if x.peerIPMask.String() != p.peerIPMask.String() {
		t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.peerIPMask, p.peerIPMask)
	}
	if x.vtep.String() != p.vtep.String() {
		t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.vtep, p.vtep)
	}
}