From 08fcc218b5985c1f81b5eaf78a0967c37523d7fa Mon Sep 17 00:00:00 2001 From: Levan Machablishvili Date: Thu, 16 Jan 2025 16:42:59 -0500 Subject: [PATCH] Add failing test --- pkg/condition/condition_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/condition/condition_test.go b/pkg/condition/condition_test.go index 44d9aa05b..87db83793 100644 --- a/pkg/condition/condition_test.go +++ b/pkg/condition/condition_test.go @@ -7,9 +7,12 @@ package condition import ( "testing" + "time" "github.com/google/go-cmp/cmp" assert "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/DataDog/datadog-operator/api/datadoghq/v2alpha1" @@ -108,3 +111,11 @@ func TestDeleteDatadogAgentStatusCondition(t *testing.T) { }) } } + +func TestDSUpdateWhenNil(t *testing.T) { + var ds *appsv1.DaemonSet + dsStatus := UpdateDaemonSetStatus(ds, []*v2alpha1.DaemonSetStatus{}, &metav1.Time{Time: time.Now()}) + dsStatus = UpdateDaemonSetStatus(ds, dsStatus, &metav1.Time{Time: time.Now()}) + dsStatus = UpdateDaemonSetStatus(ds, dsStatus, &metav1.Time{Time: time.Now()}) + assert.Equal(t, 1, len(dsStatus)) +}