|
@@ -21,6 +21,7 @@ import (
|
|
|
"github.com/docker/docker/integration-cli/daemon"
|
|
|
"gotest.tools/assert"
|
|
|
"gotest.tools/icmd"
|
|
|
+ "gotest.tools/poll"
|
|
|
)
|
|
|
|
|
|
func deleteImages(images ...string) error {
|
|
@@ -412,16 +413,16 @@ func getErrorMessage(c *testing.T, body []byte) string {
|
|
|
return strings.TrimSpace(resp.Message)
|
|
|
}
|
|
|
|
|
|
-func waitAndAssert(t assert.TestingT, timeout time.Duration, f checkF, comparison assert.BoolOrComparison, args ...interface{}) {
|
|
|
+func waitAndAssert(t *testing.T, timeout time.Duration, f interface{}, comparison interface{}, args ...interface{}) {
|
|
|
t1 := time.Now()
|
|
|
defer func() {
|
|
|
t2 := time.Now()
|
|
|
- t.(testingT).Logf("waited for %v (out of %v)", t2.Sub(t1), timeout)
|
|
|
+ t.Logf("waited for %v (out of %v)", t2.Sub(t1), timeout)
|
|
|
}()
|
|
|
|
|
|
after := time.After(timeout)
|
|
|
for {
|
|
|
- v, comment := f(t.(*testing.T))
|
|
|
+ v, comment := f.(checkF)(t)
|
|
|
args = append([]interface{}{v}, args...)
|
|
|
shouldAssert := assert.Check(t, comparison, args...)
|
|
|
select {
|
|
@@ -443,12 +444,23 @@ func waitAndAssert(t assert.TestingT, timeout time.Duration, f checkF, compariso
|
|
|
type checkF func(*testing.T) (interface{}, string)
|
|
|
type reducer func(...interface{}) interface{}
|
|
|
|
|
|
-func reducedCheck(r reducer, funcs ...checkF) checkF {
|
|
|
+func pollCheck(t *testing.T, f interface{}, compare func(x interface{}) assert.BoolOrComparison) poll.Check {
|
|
|
+ return func(poll.LogT) poll.Result {
|
|
|
+ ff := f.(checkF)
|
|
|
+ v, comment := ff(t)
|
|
|
+ if assert.Check(t, compare(v)) {
|
|
|
+ return poll.Success()
|
|
|
+ }
|
|
|
+ return poll.Continue(comment)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func reducedCheck(r reducer, funcs ...interface{}) checkF {
|
|
|
return func(c *testing.T) (interface{}, string) {
|
|
|
var values []interface{}
|
|
|
var comments []string
|
|
|
for _, f := range funcs {
|
|
|
- v, comment := f(c)
|
|
|
+ v, comment := f.(checkF)(c)
|
|
|
values = append(values, v)
|
|
|
if len(comment) > 0 {
|
|
|
comments = append(comments, comment)
|