mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-03 18:26:59 +00:00
client-go/util/consistencydetector: extend TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath to work with unstructured list
Kubernetes-commit: a2a48a475b4c98daeea3f83b8a89aa070ea4082b
This commit is contained in:
parent
2d885a2ed5
commit
503a0905c0
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
)
|
)
|
||||||
@ -78,6 +79,43 @@ func TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath(t *testin
|
|||||||
TimeoutSeconds: ptr.To(int64(39)),
|
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 {
|
for _, scenario := range scenarios {
|
||||||
t.Run(scenario.name, func(t *testing.T) {
|
t.Run(scenario.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user