history_require.go ×13

Frontier kind: Joint frontier

unlabeled · c_a682011d76e9

1 test · 3174 LOC · 113 files · introduces 1 test · 72 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges72 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
460 ranges3174 lines · 113 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

2 files ranked by introduced lines: 72 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/testing/historyrequire/history_require.go 43 introduced LOC · 13 ranges

Open complete file

249 }
250
251 > func (h HistoryRequire) PrintHistoryEvents(events []*historypb.HistoryEvent) { history_require.go
252 > _, _ = fmt.Println(h.formatHistoryEvents(events, false))
253 > }
254
255 func (h HistoryRequire) PrintHistoryCompact(history *historypb.History) {
257 }
258
259 > func (h HistoryRequire) PrintHistoryEventsCompact(events []*historypb.HistoryEvent) { history_require.go
260 > _, _ = fmt.Println(h.formatHistoryEvents(events, true))
261 > }
262
263 func (h HistoryRequire) equalHistoryEvents(
406 var eventAttrsJsonStr string
407 if !compact {
408 > eventAttrs := reflect.ValueOf(event.Attributes).Elem().Field(0).Elem().Interface() history_require.go
409 > eventAttrsMap := h.structToMap(eventAttrs)
410 > eventAttrsJsonBytes, err := json.Marshal(eventAttrsMap)
411 > require.NoError(h.t, err)
412 > eventAttrsJsonStr = " " + string(eventAttrsJsonBytes)
413 > }
414 _, _ = sb.WriteString(strings.Join([]string{eventIDStr, versionStr, event.GetEventType().String(), eventAttrsJsonStr, "\n"}, ""))
415 }
418 }
419
420 > func (h HistoryRequire) structToMap(strct any) map[string]any { history_require.go
421 > if th, ok := h.t.(helper); ok {
422 > th.Helper()
423 > }
424
425 > strctV := reflect.ValueOf(strct) history_require.go
426 > strctT := strctV.Type()
427 >
428 > ret := map[string]any{}
429 >
430 > for i := 0; i < strctV.NumField(); i++ {
431 > field := strctV.Field(i)
432 > // Skip unexported members
433 > if !publicRgx.MatchString(strctT.Field(i).Name) {
434 > continue
435 }
436 > if field.Kind() == reflect.Pointer && field.IsNil() { history_require.go
437 > continue
438 }
439 > fieldName := strctT.Field(i).Name history_require.go
440 > ret[fieldName] = h.fieldValue(field)
441 }
442
443 > return ret history_require.go
444 }
445
446 //nolint:revive // cognitive complexity 29 (> max enabled 25)
447 > func (h HistoryRequire) fieldValue(field reflect.Value) any { history_require.go
448 > if field.Kind() == reflect.Pointer && field.Elem().Kind() == reflect.Struct {
449 > return h.structToMap(field.Elem().Interface())
450 > } else if field.Kind() == reflect.Struct {
451 return h.structToMap(field.Interface())
452 > } else if field.Kind() == reflect.Slice && field.Type() != typeOfBytes { history_require.go
453 > fvSlice := make([]any, field.Len())
454 > for i := 0; i < field.Len(); i++ {
455 fvSlice[i] = h.fieldValue(field.Index(i))
456 }
457 > return fvSlice history_require.go
458 > } else if field.Kind() == reflect.Map {
459 mr := field.MapRange()
460 fvMap := make(map[string]any)
471 }
472
473 > fieldValue := field.Interface() history_require.go
474 > if fieldValueBytes, ok := fieldValue.([]byte); ok {
475 fieldValue = string(fieldValueBytes)
476 }
477
478 > return fieldValue history_require.go
479 }
480
go.temporal.io/server/common/testing/history_event_util.go 29 introduced LOC · 2 ranges

Open complete file

283 workflowFail := NewHistoryEventVertex(enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_FAILED.String())
284 workflowFail.SetDataFunc(func(input ...any) any {
285 > lastEvent := input[0].(*historypb.HistoryEvent) history_event_util.go
286 > eventID := lastEvent.GetEventId() + 1
287 > version := input[2].(int64)
288 > historyEvent := getDefaultHistoryEvent(eventID, version)
289 > historyEvent.EventType = enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_FAILED
290 > historyEvent.Attributes = &historypb.HistoryEvent_WorkflowExecutionFailedEventAttributes{WorkflowExecutionFailedEventAttributes: &historypb.WorkflowExecutionFailedEventAttributes{
291 > WorkflowTaskCompletedEventId: lastEvent.EventId,
292 > }}
293 > return historyEvent
294 > })
295 workflowCancel := NewHistoryEventVertex(enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED.String())
296 workflowCancel.SetDataFunc(func(input ...any) any {
664 childWorkflowComplete := NewHistoryEventVertex(enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_COMPLETED.String())
665 childWorkflowComplete.SetDataFunc(func(input ...any) any {
666 > lastEvent := input[0].(*historypb.HistoryEvent) history_event_util.go
667 > lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
668 > eventID := lastGeneratedEvent.GetEventId() + 1
669 > version := input[2].(int64)
670 > historyEvent := getDefaultHistoryEvent(eventID, version)
671 > historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_COMPLETED
672 > historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes{ChildWorkflowExecutionCompletedEventAttributes: &historypb.ChildWorkflowExecutionCompletedEventAttributes{
673 > Namespace: nsName.String(),
674 > NamespaceId: nsID.String(),
675 > WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
676 > InitiatedEventId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().InitiatedEventId,
677 > WorkflowExecution: &commonpb.WorkflowExecution{
678 > WorkflowId: childWorkflowID,
679 > RunId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().GetWorkflowExecution().RunId,
680 > },
681 > StartedEventId: lastEvent.EventId,
682 > }}
683 > return historyEvent
684 > })
685 childWorkflowFail := NewHistoryEventVertex(enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_FAILED.String())
686 childWorkflowFail.SetDataFunc(func(input ...any) any {