MCPcopy
hub / github.com/puma/puma-dev / pollForEvent

Function pollForEvent

cmd/puma-dev/main_test.go:182–211  ·  view source on GitHub ↗
(t *testing.T, app string, event string, reason string)

Source from the content-addressed store, hash-verified

180}
181
182func 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
213func runPlatformAgnosticTestScenarios(t *testing.T) {
214 t.Run("status", func(t *testing.T) {

Callers 1

Calls 3

getURLWithHostFunction · 0.85
LogDebugfFunction · 0.85
DoMethod · 0.80

Tested by

no test coverage detected