From 1f02c34be4a60d6b0128efe0e54b09e0f50c4d78 Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Fri, 4 Oct 2024 10:23:23 -0400 Subject: [PATCH 1/2] Add typed object earlier --- pkg/clusteragent/autoscaling/workload/controller_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) mode change 100644 => 100755 pkg/clusteragent/autoscaling/workload/controller_test.go diff --git a/pkg/clusteragent/autoscaling/workload/controller_test.go b/pkg/clusteragent/autoscaling/workload/controller_test.go old mode 100644 new mode 100755 index 71547a3847a67..cb24bad91aff3 --- a/pkg/clusteragent/autoscaling/workload/controller_test.go +++ b/pkg/clusteragent/autoscaling/workload/controller_test.go @@ -283,6 +283,7 @@ func TestDatadogPodAutoscalerTargetingClusterAgentErrors(t *testing.T) { dpa, dpaTyped := newFakePodAutoscaler(currentNs, "dpa-dca", 1, testTime, dpaSpec, datadoghq.DatadogPodAutoscalerStatus{}) f.InformerObjects = append(f.InformerObjects, dpa) + f.Objects = append(f.Objects, dpaTyped) expectedDPAError := &datadoghq.DatadogPodAutoscaler{ TypeMeta: metav1.TypeMeta{ @@ -349,9 +350,6 @@ func TestDatadogPodAutoscalerTargetingClusterAgentErrors(t *testing.T) { assert.NoError(t, err) f.RunControllerSync(true, id) - f.Objects = append(f.Objects, dpaTyped) - f.Actions = nil - f.ExpectUpdateStatusAction(expectedUnstructuredError) f.RunControllerSync(true, id) assert.Len(t, f.store.GetAll(), 1) From 70c67abe357f520218a2a7b14911b46e7433f4ea Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Fri, 4 Oct 2024 14:55:36 -0400 Subject: [PATCH 2/2] Reorder test commands for clarity --- pkg/clusteragent/autoscaling/workload/controller_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/clusteragent/autoscaling/workload/controller_test.go b/pkg/clusteragent/autoscaling/workload/controller_test.go index cb24bad91aff3..ae139c19e02b9 100755 --- a/pkg/clusteragent/autoscaling/workload/controller_test.go +++ b/pkg/clusteragent/autoscaling/workload/controller_test.go @@ -281,10 +281,16 @@ func TestDatadogPodAutoscalerTargetingClusterAgentErrors(t *testing.T) { Owner: datadoghq.DatadogPodAutoscalerLocalOwner, } + // Create object in store dpa, dpaTyped := newFakePodAutoscaler(currentNs, "dpa-dca", 1, testTime, dpaSpec, datadoghq.DatadogPodAutoscalerStatus{}) f.InformerObjects = append(f.InformerObjects, dpa) f.Objects = append(f.Objects, dpaTyped) + f.RunControllerSync(true, id) + _, found := f.store.Get(id) + assert.True(t, found) + + // Test that object gets updated with correct error status expectedDPAError := &datadoghq.DatadogPodAutoscaler{ TypeMeta: metav1.TypeMeta{ Kind: "DatadogPodAutoscaler", @@ -348,7 +354,6 @@ func TestDatadogPodAutoscalerTargetingClusterAgentErrors(t *testing.T) { } expectedUnstructuredError, err := autoscaling.ToUnstructured(expectedDPAError) assert.NoError(t, err) - f.RunControllerSync(true, id) f.ExpectUpdateStatusAction(expectedUnstructuredError) f.RunControllerSync(true, id)