| 872 | } |
| 873 | |
| 874 | func EnvWaitFor(t *testing.T, env WorkflowRun, timeout time.Duration, reason string, f func() bool) { |
| 875 | t.Helper() |
| 876 | t.Log("WaitFor", reason, time.Now()) |
| 877 | |
| 878 | deadline := time.Now().Add(timeout) |
| 879 | for !f() { |
| 880 | if time.Now().After(deadline) { |
| 881 | env.Cancel(t.Context()) |
| 882 | t.Fatal("UNEXPECTED TIMEOUT", reason, time.Now()) |
| 883 | } |
| 884 | time.Sleep(time.Second) |
| 885 | if err := t.Context().Err(); err != nil { |
| 886 | t.Fatal(reason, err) |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | func EnvWaitForFinished(t *testing.T, env WorkflowRun, timeout time.Duration) { |
| 892 | t.Helper() |