Skip to content

Commit

Permalink
test(vrf): add more mock tests
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Sep 6, 2023
1 parent d9088f9 commit bb5579d
Show file tree
Hide file tree
Showing 4 changed files with 341 additions and 9 deletions.
4 changes: 3 additions & 1 deletion pkg/evpn/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ func Test_DeleteLogicalBridge(t *testing.T) {

fname1 := resourceIDToFullName("bridges", tt.in)
opi.Bridges[testLogicalBridgeName] = protoClone(&testLogicalBridge)
opi.Bridges[testLogicalBridgeName].Name = testLogicalBridgeName

if tt.on != nil {
tt.on(mockNetlink, tt.errMsg)
Expand Down Expand Up @@ -620,7 +621,8 @@ func Test_GetLogicalBridge(t *testing.T) {
}(conn)
client := pb.NewLogicalBridgeServiceClient(conn)

opi.Bridges[testLogicalBridgeID] = protoClone(&testLogicalBridge)
opi.Bridges[testLogicalBridgeName] = protoClone(&testLogicalBridge)
opi.Bridges[testLogicalBridgeName].Name = testLogicalBridgeName

request := &pb.GetLogicalBridgeRequest{Name: tt.in}
response, err := client.GetLogicalBridge(ctx, request)
Expand Down
5 changes: 4 additions & 1 deletion pkg/evpn/port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func Test_CreateBridgePort(t *testing.T) {
client := pb.NewBridgePortServiceClient(conn)

opi.Bridges[testLogicalBridgeName] = protoClone(&testLogicalBridge)
opi.Bridges[testLogicalBridgeName].Name = testLogicalBridgeName
if tt.exist {
opi.Ports[testBridgePortName] = protoClone(&testBridgePort)
opi.Ports[testBridgePortName].Name = testBridgePortName
Expand Down Expand Up @@ -381,6 +382,7 @@ func Test_DeleteBridgePort(t *testing.T) {

fname1 := resourceIDToFullName("ports", tt.in)
opi.Ports[testBridgePortName] = protoClone(&testBridgePort)
opi.Ports[testBridgePortName].Name = testBridgePortName

request := &pb.DeleteBridgePortRequest{Name: fname1, AllowMissing: tt.missing}
response, err := client.DeleteBridgePort(ctx, request)
Expand Down Expand Up @@ -547,7 +549,8 @@ func Test_GetBridgePort(t *testing.T) {
}(conn)
client := pb.NewBridgePortServiceClient(conn)

opi.Ports[testBridgePortID] = protoClone(&testBridgePort)
opi.Ports[testBridgePortName] = protoClone(&testBridgePort)
opi.Ports[testBridgePortName].Name = testBridgePortName

request := &pb.GetBridgePortRequest{Name: tt.in}
response, err := client.GetBridgePort(ctx, request)
Expand Down
4 changes: 4 additions & 0 deletions pkg/evpn/svi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ func Test_CreateSvi(t *testing.T) {
tt.on(mockNetlink, tt.errMsg)
}
opi.Vrfs[testVrfName] = protoClone(&testVrf)
opi.Vrfs[testVrfName].Name = testVrfName
opi.Bridges[testLogicalBridgeName] = protoClone(&testLogicalBridge)
opi.Bridges[testLogicalBridgeName].Name = testLogicalBridgeName

request := &pb.CreateSviRequest{Svi: tt.in, SviId: tt.id}
response, err := client.CreateSvi(ctx, request)
Expand Down Expand Up @@ -378,6 +380,7 @@ func Test_DeleteSvi(t *testing.T) {

fname1 := resourceIDToFullName("svis", tt.in)
opi.Svis[testSviName] = protoClone(&testSvi)
opi.Svis[testSviName].Name = testSviName

request := &pb.DeleteSviRequest{Name: fname1, AllowMissing: tt.missing}
response, err := client.DeleteSvi(ctx, request)
Expand Down Expand Up @@ -546,6 +549,7 @@ func Test_GetSvi(t *testing.T) {
client := pb.NewSviServiceClient(conn)

opi.Svis[testSviName] = protoClone(&testSvi)
opi.Svis[testSviName].Name = testSviName

request := &pb.GetSviRequest{Name: tt.in}
response, err := client.GetSvi(ctx, request)
Expand Down
Loading

0 comments on commit bb5579d

Please sign in to comment.