Skip to content

Commit

Permalink
add requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: sakshi-1505 <sakshipatle.0808cs171134@gmail.com>
  • Loading branch information
sakshi-1505 committed Oct 16, 2023
1 parent 13d9bc7 commit 3deab8f
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions pkg/openstack/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ func TestLbaasV2_createLoadBalancerStatus(t *testing.T) {
type fields struct {
LoadBalancer LoadBalancer
}
type result struct {
HostName *string
IPAddress *string
}
type args struct {
service *corev1.Service
svcConf *serviceConfig
Expand All @@ -551,7 +555,7 @@ func TestLbaasV2_createLoadBalancerStatus(t *testing.T) {
name string
fields fields
args args
want *corev1.LoadBalancerStatus
want result
}{
{
name: "it should return hostname from service annotation",
Expand All @@ -574,16 +578,12 @@ func TestLbaasV2_createLoadBalancerStatus(t *testing.T) {
},
addr: "10.10.0.6",
},
want: &corev1.LoadBalancerStatus{
Ingress: []corev1.LoadBalancerIngress{
{
Hostname: "testHostName",
},
},
want: result{
HostName: getStringPointer("testHostName"),
},
},
{
name: "it should return fakehostname if proxyProtocal & IngressHostName is enabled without svc annotation",
name: "it should return fakehostname if proxyProtocol & IngressHostName is enabled without svc annotation",
fields: fields{
LoadBalancer: LoadBalancer{
opts: LoadBalancerOpts{
Expand All @@ -603,12 +603,8 @@ func TestLbaasV2_createLoadBalancerStatus(t *testing.T) {
},
addr: "10.10.0.6",
},
want: &corev1.LoadBalancerStatus{
Ingress: []corev1.LoadBalancerIngress{
{
Hostname: "10.10.0.6.ingress-suffix",
},
},
want: result{
HostName: getStringPointer("10.10.0.6.ingress-suffix"),
},
},
{
Expand All @@ -632,12 +628,8 @@ func TestLbaasV2_createLoadBalancerStatus(t *testing.T) {
},
addr: "10.10.0.6",
},
want: &corev1.LoadBalancerStatus{
Ingress: []corev1.LoadBalancerIngress{
{
IP: "10.10.0.6",
},
},
want: result{
IPAddress: getStringPointer("10.10.0.6"),
},
},
}
Expand All @@ -646,7 +638,12 @@ func TestLbaasV2_createLoadBalancerStatus(t *testing.T) {
lbaas := &LbaasV2{
LoadBalancer: tt.fields.LoadBalancer,
}
assert.Equal(t, tt.want, lbaas.createLoadBalancerStatus(tt.args.service, tt.args.svcConf, tt.args.addr))
if tt.want.HostName != nil {
assert.Equal(t, *tt.want.HostName, lbaas.createLoadBalancerStatus(tt.args.service, tt.args.svcConf, tt.args.addr).Ingress[0].Hostname)
}
if tt.want.IPAddress != nil {
assert.Equal(t, *tt.want.IPAddress, lbaas.createLoadBalancerStatus(tt.args.service, tt.args.svcConf, tt.args.addr).Ingress[0].IP)
}
})
}
}
Expand Down Expand Up @@ -937,6 +934,7 @@ func Test_buildPoolCreateOpt(t *testing.T) {
})
}
}

func Test_getSecurityGroupName(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -1085,3 +1083,7 @@ func TestLbaasV2_updateServiceAnnotations(t *testing.T) {

assert.ElementsMatch(t, expectedAnnotations, serviceAnnotations)
}

func getStringPointer(v string) *string {
return &v
}

0 comments on commit 3deab8f

Please sign in to comment.