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