Skip to content

Commit

Permalink
More suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
robbavey committed Apr 6, 2023
1 parent d2dd060 commit cd90d6a
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions pkg/controller/logstash/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestReconcileServices(t *testing.T) {
"common.k8s.elastic.co/type": "logstash",
"logstash.k8s.elastic.co/name": "logstash",
},
ClusterIP: "None",
ClusterIP: "",
Ports: []corev1.ServicePort{
{Name: "api", Protocol: "TCP", Port: 9200},
},
Expand Down Expand Up @@ -198,8 +198,7 @@ func TestReconcileServices(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
defaultSvc := defaultServiceFromOwner(&tc.logstash)
client := k8s.NewFakeClient(&tc.logstash, defaultSvc)
client := k8s.NewFakeClient()
params := Params{
Context: context.Background(),
Client: client,
Expand All @@ -215,36 +214,3 @@ func TestReconcileServices(t *testing.T) {
})
}
}

func defaultServiceFromOwner(owner *logstashv1alpha1.Logstash) *corev1.Service {
trueVal := true
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "logstash-ls-api",
Namespace: "test",
Labels: map[string]string{
"common.k8s.elastic.co/type": "logstash",
"logstash.k8s.elastic.co/name": "logstash",
},
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "logstash.k8s.elastic.co/v1alpha1",
Kind: "Logstash",
Name: owner.Name,
Controller: &trueVal,
BlockOwnerDeletion: &trueVal,
},
},
},
Spec: corev1.ServiceSpec{
Selector: map[string]string{
"common.k8s.elastic.co/type": "logstash",
"logstash.k8s.elastic.co/name": "logstash",
},
ClusterIP: "None",
Ports: []corev1.ServicePort{
{Name: "api", Protocol: "TCP", Port: 9600},
},
},
}
}

0 comments on commit cd90d6a

Please sign in to comment.