github.com/jfrazelle/docker@v1.1.2-0.20210712172922-bf78e25fe508/libnetwork/drivers/overlay/peerdb_test.go (about) 1 // +build linux 2 3 package overlay 4 5 import ( 6 "net" 7 "testing" 8 9 _ "github.com/docker/docker/libnetwork/testutils" 10 ) 11 12 func TestPeerMarshal(t *testing.T) { 13 _, ipNet, _ := net.ParseCIDR("192.168.0.1/24") 14 p := &peerEntry{eid: "eid", 15 isLocal: true, 16 peerIPMask: ipNet.Mask, 17 vtep: ipNet.IP} 18 entryDB := p.MarshalDB() 19 x := entryDB.UnMarshalDB() 20 if x.eid != p.eid { 21 t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.eid, p.eid) 22 } 23 if x.isLocal != p.isLocal { 24 t.Fatalf("Incorrect Unmarshalling for isLocal: %v != %v", x.isLocal, p.isLocal) 25 } 26 if x.peerIPMask.String() != p.peerIPMask.String() { 27 t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.peerIPMask, p.peerIPMask) 28 } 29 if x.vtep.String() != p.vtep.String() { 30 t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.vtep, p.vtep) 31 } 32 }