Skip to content

Commit

Permalink
Add UT
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <wenqiq@vmware.com>
  • Loading branch information
wenqiq committed Sep 12, 2024
1 parent ba70b39 commit ac64926
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/nsx/services/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ func (vpcService *VPCService) EdgeClusterEnabled(nc *common.VPCNetworkConfigInfo
if getErr != nil {
return getErr
}
log.Info("VPC connectivity profile retrieved", "serviceGateway", *vpcConnectivityProfile.ServiceGateway)
log.Info("VPC connectivity profile retrieved", "profile", *vpcConnectivityProfile)
return nil
}); err != nil {
log.Error(err, "Failed to retrieve VPC connectivity profile", "profile", nc.VPCConnectivityProfile)
Expand Down Expand Up @@ -1096,6 +1096,7 @@ func (vpcService *VPCService) GetLBProvider() LBProvider {
log.Info("lb provider", "provider", globalLbProvider)
return globalLbProvider
}

func (vpcService *VPCService) getLBProvider(edgeEnable bool) LBProvider {
// if no Alb endpoint found, return nsx-lb
// if found, and nsx lbs found, return nsx-lb
Expand Down
8 changes: 8 additions & 0 deletions pkg/nsx/services/vpc/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,14 @@ func TestEdgeClusterEnabled(t *testing.T) {
enable = vpcService.EdgeClusterEnabled(&nc)
assert.Equal(t, false, enable)
patch.Reset()

// Simulate the scenario when the VpcConnectivityProfile value returned by NSX is nil.
patch = gomonkey.ApplyMethod(reflect.TypeOf(vpcService), "GetVpcConnectivityProfile", func(_ *VPCService, _ *common.VPCNetworkConfigInfo, _ string) (*model.VpcConnectivityProfile, error) {
return &model.VpcConnectivityProfile{}, nil
})
enable = vpcService.EdgeClusterEnabled(&nc)
assert.Equal(t, false, enable)
patch.Reset()
}

func TestGetLbProvider(t *testing.T) {
Expand Down

0 comments on commit ac64926

Please sign in to comment.