(t *testing.T, app string, event string, reason string)
| 180 | } |
| 181 | |
| 182 | func pollForEvent(t *testing.T, app string, event string, reason string) error { |
| 183 | return retry.Do( |
| 184 | func() error { |
| 185 | body := getURLWithHost(t, fmt.Sprintf("http://localhost:%d/events", *fHTTPPort), "puma-dev") |
| 186 | eachEvent := strings.Split(body, "\n") |
| 187 | |
| 188 | for _, line := range eachEvent { |
| 189 | var rawEvt interface{} |
| 190 | if err := json.Unmarshal([]byte(line), &rawEvt); err != nil { |
| 191 | assert.FailNow(t, err.Error()) |
| 192 | } |
| 193 | evt := rawEvt.(map[string]interface{}) |
| 194 | LogDebugf("%+v", evt) |
| 195 | |
| 196 | eventFound := (app == "" || evt["app"] == app) && |
| 197 | (event == "" || evt["event"] == event) && |
| 198 | (reason == "" || evt["reason"] == reason) |
| 199 | |
| 200 | if eventFound { |
| 201 | return nil |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | return errors.New("not found") |
| 206 | }, |
| 207 | retry.RetryIf(func(err error) bool { |
| 208 | return err.Error() == "not found" |
| 209 | }), |
| 210 | ) |
| 211 | } |
| 212 | |
| 213 | func runPlatformAgnosticTestScenarios(t *testing.T) { |
| 214 | t.Run("status", func(t *testing.T) { |
no test coverage detected