Skip to content

Commit 853188a

Browse files
committed
Add Test case
1 parent 59510a1 commit 853188a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

internal/controller/provisioner/objects.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ const (
4646

4747
var emptyDirVolumeSource = corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}
4848

49+
func autoscalingEnabled(dep *ngfAPIv1alpha2.DeploymentSpec) bool {
50+
return dep != nil && dep.Autoscaling.Enabled
51+
}
52+
53+
func cloneHPAAnnotationMap(src map[string]string) map[string]string {
54+
if src == nil {
55+
return nil
56+
}
57+
annotations := make(map[string]string, len(src))
58+
for k, v := range src {
59+
annotations[k] = v
60+
}
61+
return annotations
62+
}
63+
4964
func (p *NginxProvisioner) buildNginxResourceObjects(
5065
resourceName string,
5166
gateway *gatewayv1.Gateway,

internal/controller/provisioner/objects_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
287287
},
288288
Deployment: &ngfAPIv1alpha2.DeploymentSpec{
289289
Replicas: helpers.GetPointer[int32](3),
290+
Autoscaling: ngfAPIv1alpha2.HPASpec{
291+
Enabled: true,
292+
MinReplicas: helpers.GetPointer[int32](1),
293+
MaxReplicas: 5,
294+
TargetMemoryUtilizationPercentage: helpers.GetPointer[int32](60),
295+
},
290296
Pod: ngfAPIv1alpha2.PodSpec{
291297
TerminationGracePeriodSeconds: helpers.GetPointer[int64](25),
292298
},
@@ -314,7 +320,7 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
314320
objects, err := provisioner.buildNginxResourceObjects(resourceName, gateway, nProxyCfg)
315321
g.Expect(err).ToNot(HaveOccurred())
316322

317-
g.Expect(objects).To(HaveLen(6))
323+
g.Expect(objects).To(HaveLen(7))
318324

319325
cmObj := objects[1]
320326
cm, ok := cmObj.(*corev1.ConfigMap)

0 commit comments

Comments
 (0)