Skip to content

Commit

Permalink
address requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: sakshi-1505 <[email protected]>
  • Loading branch information
sakshi-1505 committed Oct 16, 2023
1 parent 911e7eb commit 6b64ce3
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions pkg/openstack/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,6 @@ func Test_getListenerProtocol(t *testing.T) {
}

func TestLbaasV2_checkListenerPorts(t *testing.T) {
type fields struct {
LoadBalancer LoadBalancer
}
type args struct {
service *corev1.Service
curListenerMapping map[listenerKey]*listeners.Listener
Expand All @@ -547,7 +544,6 @@ func TestLbaasV2_checkListenerPorts(t *testing.T) {
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
Expand All @@ -571,16 +567,13 @@ func TestLbaasV2_checkListenerPorts(t *testing.T) {
Port: 9090,
}: {
ID: "listenerid",
Tags: []string{"test-lb", "test-lb2"},
Tags: []string{"test-lb"},
},
},
isLBOwner: false,
lbName: "test-lb",
},
wantErr: false,
fields: fields{
LoadBalancer: LoadBalancer{},
},
},
{
name: "error is thrown if loadbalancer doesn't matches & if port is already in use by a service",
Expand Down Expand Up @@ -609,9 +602,6 @@ func TestLbaasV2_checkListenerPorts(t *testing.T) {
lbName: "test-lb2",
},
wantErr: true,
fields: fields{
LoadBalancer: LoadBalancer{},
},
},
{
name: "error is not thrown if lbOwner is present & no tags on service",
Expand Down Expand Up @@ -639,9 +629,34 @@ func TestLbaasV2_checkListenerPorts(t *testing.T) {
lbName: "test-lb",
},
wantErr: false,
fields: fields{
LoadBalancer: LoadBalancer{},
},
{
name: "error is not thrown if lbOwner is true & there are tags on service",
args: args{
service: &corev1.Service{
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "service",
Protocol: "http",
Port: 9091,
},
},
},
},
curListenerMapping: map[listenerKey]*listeners.Listener{
{
Protocol: "https",
Port: 9090,
}: {
ID: "listenerid",
Tags: []string{"test-lb"},
},
},
isLBOwner: true,
lbName: "test-lb",
},
wantErr: false,
},
{
name: "error is not thrown if listener key doesn't match port & protocol",
Expand All @@ -663,22 +678,19 @@ func TestLbaasV2_checkListenerPorts(t *testing.T) {
Port: 9090,
}: {
ID: "listenerid",
Tags: []string{"test-lb", "test-lb-1"},
Tags: []string{"test-lb"},
},
},
isLBOwner: false,
lbName: "test-lb",
},
wantErr: false,
fields: fields{
LoadBalancer: LoadBalancer{},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
lbaas := &LbaasV2{
LoadBalancer: tt.fields.LoadBalancer,
LoadBalancer: LoadBalancer{},
}
err := lbaas.checkListenerPorts(tt.args.service, tt.args.curListenerMapping, tt.args.isLBOwner, tt.args.lbName)
if tt.wantErr == true {
Expand Down

0 comments on commit 6b64ce3

Please sign in to comment.