github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/libnetwork/drivers/overlay/peerdb_test.go (about)

     1  //go:build linux
     2  
     3  package overlay
     4  
     5  import (
     6  	"net"
     7  	"testing"
     8  )
     9  
    10  func TestPeerMarshal(t *testing.T) {
    11  	_, ipNet, _ := net.ParseCIDR("192.168.0.1/24")
    12  	p := &peerEntry{
    13  		eid:        "eid",
    14  		isLocal:    true,
    15  		peerIPMask: ipNet.Mask,
    16  		vtep:       ipNet.IP,
    17  	}
    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  }