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)) +}