From a0a59190d55c501385fc106ec56d6dd9ec0d3913 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 6 Apr 2016 07:30:18 -0700 Subject: [PATCH] fix(e2e): fix return on wait func --- test/e2e/helm_test.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/e2e/helm_test.go b/test/e2e/helm_test.go index 98de7c1c1..81b7bee4a 100644 --- a/test/e2e/helm_test.go +++ b/test/e2e/helm_test.go @@ -64,9 +64,9 @@ func TestHelm(t *testing.T) { "--expandybird-image", expandybirdImage, "--manager-image", managerImage, ) - wait(func() bool { - return helm.Running() - }) + if err := wait(helm.Running); err != nil { + t.Fatal(err) + } } // Add repo if it does not exsit @@ -85,10 +85,9 @@ func TestHelm(t *testing.T) { *chart, ) - err := wait(func() bool { + if err := wait(func() bool { return kube.Run("get", "pods").Match("redis.*Running") - }) - if err != nil { + }); err != nil { t.Fatal(err) } t.Log(kube.Run("get", "pods").Stdout()) @@ -112,16 +111,15 @@ func TestHelm(t *testing.T) { } } -func wait(fn func() bool) error { +type conditionFunc func() bool + +func wait(fn conditionFunc) error { for start := time.Now(); time.Since(start) < timeout; time.Sleep(poll) { if fn() { - continue + return nil } } - if !fn() { - return fmt.Errorf("Polling timeout") - } - return nil + return fmt.Errorf("Polling timeout") } func genName() string {