storage/testing/utils: add helper functions
Kubernetes-commit: 3a96baf3fa8e837159b27b98b05c5024143b06a3
This commit is contained in:
parent
a4c66a9ba7
commit
3c3bb86696
|
|
@ -187,6 +187,29 @@ func testCheckStop(t *testing.T, w watch.Interface) {
|
|||
}
|
||||
}
|
||||
|
||||
func testCheckResultsInStrictOrder(t *testing.T, w watch.Interface, expectedEvents []watch.Event) {
|
||||
for _, expectedEvent := range expectedEvents {
|
||||
testCheckResult(t, w, expectedEvent)
|
||||
}
|
||||
}
|
||||
|
||||
func testCheckResultsInRandomOrder(t *testing.T, w watch.Interface, expectedEvents []watch.Event) {
|
||||
for range expectedEvents {
|
||||
testCheckResultFunc(t, w, func(actualEvent watch.Event) {
|
||||
ExpectContains(t, "unexpected event", toInterfaceSlice(expectedEvents), actualEvent)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testCheckNoMoreResults(t *testing.T, w watch.Interface) {
|
||||
select {
|
||||
case e := <-w.ResultChan():
|
||||
t.Errorf("Unexpected: %#v event received, expected no events", e)
|
||||
case <-time.After(time.Second):
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func toInterfaceSlice[T any](s []T) []interface{} {
|
||||
result := make([]interface{}, len(s))
|
||||
for i, v := range s {
|
||||
|
|
|
|||
Loading…
Reference in New Issue