fix(e2e): fix return on wait func

pull/606/head
Adam Reese 10 years ago
parent ee813c8cab
commit a0a59190d5

@ -64,9 +64,9 @@ func TestHelm(t *testing.T) {
"--expandybird-image", expandybirdImage, "--expandybird-image", expandybirdImage,
"--manager-image", managerImage, "--manager-image", managerImage,
) )
wait(func() bool { if err := wait(helm.Running); err != nil {
return helm.Running() t.Fatal(err)
}) }
} }
// Add repo if it does not exsit // Add repo if it does not exsit
@ -85,10 +85,9 @@ func TestHelm(t *testing.T) {
*chart, *chart,
) )
err := wait(func() bool { if err := wait(func() bool {
return kube.Run("get", "pods").Match("redis.*Running") return kube.Run("get", "pods").Match("redis.*Running")
}) }); err != nil {
if err != nil {
t.Fatal(err) t.Fatal(err)
} }
t.Log(kube.Run("get", "pods").Stdout()) t.Log(kube.Run("get", "pods").Stdout())
@ -112,17 +111,16 @@ 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) { for start := time.Now(); time.Since(start) < timeout; time.Sleep(poll) {
if fn() { if fn() {
continue return nil
} }
} }
if !fn() {
return fmt.Errorf("Polling timeout") return fmt.Errorf("Polling timeout")
} }
return nil
}
func genName() string { func genName() string {
return fmt.Sprintf("e2e-%d", rand.Uint32()) return fmt.Sprintf("e2e-%d", rand.Uint32())

Loading…
Cancel
Save