Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Nov 21, 2023
1 parent 22da6ea commit 15701f5
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions controllers/limitador_controller_ports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var _ = Describe("Limitador controller manages ports", func() {
Context("Creating a new Limitador object with specific ports", func() {
var limitadorObj *limitadorv1alpha1.Limitador

var httpPortNumber int32 = 8000
var grpcPortNumber int32 = 8001
var httpPortNumber int32 = limitadorv1alpha1.DefaultServiceHTTPPort + 100

Check failure on line 35 in controllers/limitador_controller_ports_test.go

View workflow job for this annotation

GitHub Actions / Lint

ST1023: should omit type int32 from declaration; it will be inferred from the right-hand side (stylecheck)
var grpcPortNumber int32 = limitadorv1alpha1.DefaultServiceGRPCPort + 100

Check failure on line 36 in controllers/limitador_controller_ports_test.go

View workflow job for this annotation

GitHub Actions / Lint

ST1023: should omit type int32 from declaration; it will be inferred from the right-hand side (stylecheck)

httpPort := &limitadorv1alpha1.TransportProtocol{Port: &httpPortNumber}
grpcPort := &limitadorv1alpha1.TransportProtocol{Port: &grpcPortNumber}
Expand Down Expand Up @@ -131,8 +131,8 @@ var _ = Describe("Limitador controller manages ports", func() {
Context("Updating limitador object with new custom ports", func() {
var limitadorObj *limitadorv1alpha1.Limitador

var httpPortNumber int32 = 8000
var grpcPortNumber int32 = 8001
var httpPortNumber int32 = limitadorv1alpha1.DefaultServiceHTTPPort + 100

Check failure on line 134 in controllers/limitador_controller_ports_test.go

View workflow job for this annotation

GitHub Actions / Lint

ST1023: should omit type int32 from declaration; it will be inferred from the right-hand side (stylecheck)
var grpcPortNumber int32 = limitadorv1alpha1.DefaultServiceGRPCPort + 100

httpPort := &limitadorv1alpha1.TransportProtocol{Port: &httpPortNumber}
grpcPort := &limitadorv1alpha1.TransportProtocol{Port: &grpcPortNumber}
Expand Down Expand Up @@ -209,12 +209,14 @@ var _ = Describe("Limitador controller manages ports", func() {
Name: limitador.ServiceName(limitadorObj),
}, service)
Expect(err).NotTo(HaveOccurred())
Expect(deployment.Spec.Template.Spec.Containers[0].Ports).To(ContainElements(
v1.ContainerPort{
Name: "http", ContainerPort: httpPortNumber, Protocol: v1.ProtocolTCP,
Expect(service.Spec.Ports).To(ContainElements(
v1.ServicePort{
Name: "http", Port: limitadorv1alpha1.DefaultServiceHTTPPort,
Protocol: v1.ProtocolTCP, TargetPort: intstr.FromString("http"),
},
v1.ContainerPort{
Name: "grpc", ContainerPort: grpcPortNumber, Protocol: v1.ProtocolTCP,
v1.ServicePort{
Name: "grpc", Port: limitadorv1alpha1.DefaultServiceGRPCPort,
Protocol: v1.ProtocolTCP, TargetPort: intstr.FromString("grpc"),
},
))

Expand Down Expand Up @@ -266,10 +268,10 @@ var _ = Describe("Limitador controller manages ports", func() {
"/home/limitador/etc/limitador-config.yaml",
"memory",
})
livenessProbeMatch := deployment.Spec.Template.Spec.Containers[0].LivenessProbe.
ProbeHandler.HTTPGet.Port == intstr.FromInt(int(httpPortNumber))
readinessProbeMatch := deployment.Spec.Template.Spec.Containers[0].ReadinessProbe.
ProbeHandler.HTTPGet.Port == intstr.FromInt(int(httpPortNumber))
livenessProbeMatch := reflect.DeepEqual(newDeployment.Spec.Template.Spec.Containers[0].LivenessProbe.
ProbeHandler.HTTPGet.Port, intstr.FromInt(int(httpPortNumber)))
readinessProbeMatch := reflect.DeepEqual(newDeployment.Spec.Template.Spec.Containers[0].ReadinessProbe.
ProbeHandler.HTTPGet.Port, intstr.FromInt(int(httpPortNumber)))

return !slices.Contains(
[]bool{
Expand Down

0 comments on commit 15701f5

Please sign in to comment.