MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / execWSRead

Method execWSRead

tests/contract/contract_test.go:472–513  ·  view source on GitHub ↗
(t *testing.T, s *step)

Source from the content-addressed store, hash-verified

470}
471
472func (r *runner) execWSRead(t *testing.T, s *step) {
473 t.Helper()
474 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
475 defer cancel()
476
477 _, data, err := r.wsConn.Read(ctx)
478 if err != nil {
479 t.Fatalf("step %s: ws read: %v", s.ID, err)
480 }
481
482 var notif map[string]interface{}
483 if err := json.Unmarshal(data, &notif); err != nil {
484 t.Fatalf("step %s: unmarshal notification: %v", s.ID, err)
485 }
486
487 if s.Expect == nil {
488 return
489 }
490 for _, field := range s.Expect.FieldsPresent {
491 resolvedField := r.resolve(field)
492 if _, ok := notif[resolvedField]; !ok {
493 t.Fatalf("step %s: expected field %q in notification", s.ID, resolvedField)
494 }
495 }
496 for _, field := range s.Expect.FieldsAbsent {
497 resolvedField := r.resolve(field)
498 if _, ok := notif[resolvedField]; ok {
499 t.Fatalf("step %s: unexpected field %q in notification", s.ID, resolvedField)
500 }
501 }
502 for key, expected := range s.Expect.FieldMatch {
503 resolvedKey := r.resolve(key)
504 actual, ok := notif[resolvedKey]
505 if !ok {
506 t.Fatalf("step %s: field %q not found in notification", s.ID, resolvedKey)
507 }
508 resolvedExpected := r.resolveValue(expected)
509 if !valuesEqual(actual, resolvedExpected) {
510 t.Fatalf("step %s: field %q = %v, want %v", s.ID, resolvedKey, actual, resolvedExpected)
511 }
512 }
513}
514
515func (r *runner) execVerifyAndRetry(t *testing.T, s *step) {
516 t.Helper()

Callers 1

executeStepsMethod · 0.95

Calls 3

resolveMethod · 0.95
resolveValueMethod · 0.95
valuesEqualFunction · 0.70

Tested by

no test coverage detected