fix issue 6561

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2023-08-01 21:10:01 +08:00
parent 3e631ca466
commit d6134ec444
10 changed files with 166 additions and 9 deletions
@@ -27,6 +27,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -141,6 +142,18 @@ func initDataDownloadReconcilerWithError(objects []runtime.Object, needError ...
}
func TestDataDownloadReconcile(t *testing.T) {
daemonSet := &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Namespace: "velero",
Name: "node-agent",
},
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
},
Spec: appsv1.DaemonSetSpec{},
}
tests := []struct {
name string
dd *velerov2alpha1api.DataDownload
@@ -283,7 +296,7 @@ func TestDataDownloadReconcile(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
var objs []runtime.Object
if test.targetPVC != nil {
objs = []runtime.Object{test.targetPVC}
objs = []runtime.Object{test.targetPVC, daemonSet}
}
r, err := initDataDownloadReconciler(objs, test.needErrs...)
require.NoError(t, err)