Skip to content

Commit a2a48a4

Browse files
committed
client-go/util/consistencydetector: extend TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath to work with unstructured list
1 parent c590442 commit a2a48a4

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

staging/src/k8s.io/client-go/util/consistencydetector/list_data_consistency_detector_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
v1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2728
"k8s.io/apimachinery/pkg/runtime"
2829
"k8s.io/utils/ptr"
2930
)
@@ -78,6 +79,43 @@ func TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath(t *testin
7879
TimeoutSeconds: ptr.To(int64(39)),
7980
},
8081
},
82+
{
83+
name: "list detector works with a unstructured list",
84+
listResponse: &unstructured.UnstructuredList{
85+
Object: map[string]interface{}{
86+
"apiVersion": "vTest",
87+
"kind": "rTestList",
88+
"metadata": map[string]interface{}{
89+
"resourceVersion": "3",
90+
},
91+
},
92+
Items: []unstructured.Unstructured{
93+
*makeUnstructuredObject("vTest", "rTest", "item1"),
94+
*makeUnstructuredObject("vTest", "rTest", "item2"),
95+
*makeUnstructuredObject("vTest", "rTest", "item3"),
96+
},
97+
},
98+
retrievedListOptions: metav1.ListOptions{TimeoutSeconds: ptr.To(int64(39))},
99+
retrievedList: &unstructured.UnstructuredList{
100+
Object: map[string]interface{}{
101+
"apiVersion": "vTest",
102+
"kind": "rTestList",
103+
"metadata": map[string]interface{}{
104+
"resourceVersion": "3",
105+
},
106+
},
107+
Items: []unstructured.Unstructured{
108+
*makeUnstructuredObject("vTest", "rTest", "item1"),
109+
*makeUnstructuredObject("vTest", "rTest", "item2"),
110+
*makeUnstructuredObject("vTest", "rTest", "item3"),
111+
},
112+
},
113+
expectedRequestOptions: metav1.ListOptions{
114+
ResourceVersion: "3",
115+
ResourceVersionMatch: metav1.ResourceVersionMatchExact,
116+
TimeoutSeconds: ptr.To(int64(39)),
117+
},
118+
},
81119
}
82120
for _, scenario := range scenarios {
83121
t.Run(scenario.name, func(t *testing.T) {

0 commit comments

Comments
 (0)