Skip to content

Commit

Permalink
Merge pull request #1187 from KubeKyrie/add-ut-0329
Browse files Browse the repository at this point in the history
add ut
  • Loading branch information
ErikJiang authored Mar 29, 2024
2 parents a4b599e + 924e896 commit 97a3193
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/controllers/infomanifest/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -959,6 +960,28 @@ func TestReconcile(t *testing.T) {
},
want: true,
},
{
name: "list manifests error",
args: func() bool {
fetchTestingFake(controller.InfoManifestClientSet.KubeanV1alpha1()).PrependReactor("list", "manifests", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return true, nil, fmt.Errorf("this is error when list manifests")
})
result, err := controller.Reconcile(context.Background(), controllerruntime.Request{NamespacedName: types.NamespacedName{Name: manifestName}})
return err == nil && result.RequeueAfter == Loop
},
want: true,
},
{
name: "list manifests error and isNotFound",
args: func() bool {
fetchTestingFake(controller.InfoManifestClientSet.KubeanV1alpha1()).PrependReactor("list", "manifests", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return true, nil, errors.NewNotFound(manifestv1alpha1.Resource("manifests"), "manifest-name")
})
result, err := controller.Reconcile(context.Background(), controllerruntime.Request{NamespacedName: types.NamespacedName{Name: manifestName}})
return err == nil && result.Requeue == false
},
want: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down

0 comments on commit 97a3193

Please sign in to comment.