history_require.go ×17

Frontier kind: Joint frontier

unlabeled · c_97f2b37b9db2

2 tests · 2271 LOC · 106 files · introduces 1 test · 39 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges39 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
362 ranges2271 lines · 106 files · Browse complete extent
All tests (intent)
2 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 39 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/testing/historyrequire/history_require.go 39 introduced LOC · 17 ranges

Open complete file

344 }
345
346 > sanitizeEventID := expectedHistoryEvents[0].GetEventId() == 0 history_require.go
347 > sanitizeVersion := expectedHistoryEvents[0].GetVersion() == 0
348 >
349 > if !sanitizeEventID && !sanitizeVersion {
350 return actualHistoryEvents
351 }
352
353 > var sanitizedActualHistoryEvents []*historypb.HistoryEvent history_require.go
354 > for _, actualHistoryEvent := range actualHistoryEvents {
355 > sanitizedActualHistoryEvent := proto.Clone(actualHistoryEvent).(*historypb.HistoryEvent)
356 > if sanitizeEventID {
357 sanitizedActualHistoryEvent.EventId = 0
358 }
359 > if sanitizeVersion { history_require.go
360 > sanitizedActualHistoryEvent.Version = 0
361 > }
362 > sanitizedActualHistoryEvents = append(sanitizedActualHistoryEvents, sanitizedActualHistoryEvent)
363 }
364 > return sanitizedActualHistoryEvents history_require.go
365 }
366
377 continue
378 }
379 > actualHistoryEvent := actualHistoryEvents[i] history_require.go
380 > actualEventAttributes := reflect.ValueOf(actualHistoryEvent.Attributes).Elem().Field(0).Elem()
381 > h.equalExpectedMapToActualAttributes(expectedEventAttributes, actualEventAttributes, actualHistoryEvent.EventId, "")
382 }
383 }
480
481 //nolint:revive // cognitive complexity 26 (> max enabled 25)
482 > func (h HistoryRequire) equalExpectedMapToActualAttributes(expectedMap map[string]any, actualAttributesV reflect.Value, eventID int64, attrPrefix string) { history_require.go
483 > if th, ok := h.t.(helper); ok {
484 > th.Helper()
485 > }
486
487 > if actualAttributesV.Kind() == reflect.Pointer { history_require.go
488 actualAttributesV = actualAttributesV.Elem()
489 }
490
491 > for attrName, expectedValue := range expectedMap { history_require.go
492 > var actualV reflect.Value
493 > if actualAttributesV.Kind() == reflect.Map {
494 actualV = actualAttributesV.MapIndex(reflect.ValueOf(attrName))
495 > } else if actualAttributesV.Kind() == reflect.Struct { history_require.go
496 > actualV = actualAttributesV.FieldByName(attrName)
497 > } else {
498 if attrPrefix == "" {
499 attrPrefix = "."
502 }
503
504 > if actualV.Kind() == reflect.Invalid { history_require.go
505 require.Failf(h.t, "", "Expected property %s.%s wasn't found for EventID=%v", attrPrefix, attrName, eventID)
506 }
507
508 > if expectedValue == nil { history_require.go
509 if !actualV.IsNil() {
510 require.Failf(h.t, "", "Value of property %s.%s for EventID=%v expected to be nil", attrPrefix, attrName, eventID)
513 }
514
515 > if es, ok := expectedValue.([]any); ok { history_require.go
516 for i, ei := range es {
517 eim := ei.(map[string]any)
521 }
522
523 > if em, ok := expectedValue.(map[string]any); ok { history_require.go
524 if actualV.IsNil() {
525 require.Failf(h.t, "", "Value of property %s.%s for EventID=%v expected to be struct or map but was nil", attrPrefix, attrName, eventID)
530 }
531
532 > actualValue := actualV.Interface() history_require.go
533 > // Actual bytes are expressed as strings in expected history.
534 > if actualValueBytes, ok := actualValue.([]byte); ok {
535 actualValue = string(actualValueBytes)
536 }
537
538 > require.EqualValues(h.t, expectedValue, actualValue, "Values of %s.%s property are not equal for EventID=%v", attrPrefix, attrName, eventID) history_require.go
539 }
540 }
597 break
598 }
599 > _, _ = jb.WriteString(fields[i]) history_require.go
600 > _, _ = jb.WriteRune(' ')
601 }
602 var eventAttrs map[string]any
603 if jb.Len() > 0 {
604 > err = json.Unmarshal([]byte(jb.String()), &eventAttrs) history_require.go
605 > if err != nil {
606 require.FailNowf(h.t, err.Error(), "Failed to unmarshal attributes %q for event on line %d", jb.String(), lineNum+1)
607 }