diff --git a/util/consistencydetector/list_data_consistency_detector_test.go b/util/consistencydetector/list_data_consistency_detector_test.go index 0a0debd7..945e0731 100644 --- a/util/consistencydetector/list_data_consistency_detector_test.go +++ b/util/consistencydetector/list_data_consistency_detector_test.go @@ -24,6 +24,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" ) @@ -78,6 +79,43 @@ func TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath(t *testin TimeoutSeconds: ptr.To(int64(39)), }, }, + { + name: "list detector works with a unstructured list", + listResponse: &unstructured.UnstructuredList{ + Object: map[string]interface{}{ + "apiVersion": "vTest", + "kind": "rTestList", + "metadata": map[string]interface{}{ + "resourceVersion": "3", + }, + }, + Items: []unstructured.Unstructured{ + *makeUnstructuredObject("vTest", "rTest", "item1"), + *makeUnstructuredObject("vTest", "rTest", "item2"), + *makeUnstructuredObject("vTest", "rTest", "item3"), + }, + }, + retrievedListOptions: metav1.ListOptions{TimeoutSeconds: ptr.To(int64(39))}, + retrievedList: &unstructured.UnstructuredList{ + Object: map[string]interface{}{ + "apiVersion": "vTest", + "kind": "rTestList", + "metadata": map[string]interface{}{ + "resourceVersion": "3", + }, + }, + Items: []unstructured.Unstructured{ + *makeUnstructuredObject("vTest", "rTest", "item1"), + *makeUnstructuredObject("vTest", "rTest", "item2"), + *makeUnstructuredObject("vTest", "rTest", "item3"), + }, + }, + expectedRequestOptions: metav1.ListOptions{ + ResourceVersion: "3", + ResourceVersionMatch: metav1.ResourceVersionMatchExact, + TimeoutSeconds: ptr.To(int64(39)), + }, + }, } for _, scenario := range scenarios { t.Run(scenario.name, func(t *testing.T) {