@@ -140,9 +140,9 @@ func TestHistoryEventToString(t *testing.T) {
140140 assert .Equal (t , expected , strVal )
141141}
142142
143- // This just tests that we pick the right attibutes to return
143+ // This just tests that we pick the right attributes to return
144144// the other attributes will be nil
145- func Test_getData (t * testing.T ) {
145+ func Test_getHistoryEventData (t * testing.T ) {
146146 cases := []struct {
147147 event * s.HistoryEvent
148148 expected interface {}
@@ -316,7 +316,97 @@ func Test_getData(t *testing.T) {
316316 name , err := tc .event .GetEventType ().MarshalText ()
317317 require .NoError (t , err )
318318 t .Run (string (name ), func (t * testing.T ) {
319- require .Equal (t , tc .expected , getData (tc .event ))
319+ require .Equal (t , tc .expected , getHistoryEventData (tc .event ))
320+ })
321+ }
322+ }
323+
324+ func TestDecisionToString (t * testing.T ) {
325+ decision := & s.Decision {
326+ DecisionType : toPtr (s .DecisionTypeScheduleActivityTask ),
327+ ScheduleActivityTaskDecisionAttributes : & s.ScheduleActivityTaskDecisionAttributes {
328+ ActivityId : toPtr ("activity-id" ),
329+ ActivityType : & s.ActivityType {Name : toPtr ("activity-type" )},
330+ },
331+ }
332+
333+ strVal := DecisionToString (decision )
334+ expected := "ScheduleActivityTask: (ActivityId:activity-id, ActivityType:(Name:activity-type), Input:[])"
335+ require .Equal (t , expected , strVal )
336+ }
337+
338+ // This just tests that we pick the right attributes to return
339+ // the other attributes will be nil
340+ func Test_decisionGetData (t * testing.T ) {
341+ cases := []struct {
342+ decision * s.Decision
343+ expected interface {}
344+ }{
345+ {
346+ decision : & s.Decision {
347+ DecisionType : toPtr (s .DecisionTypeScheduleActivityTask ),
348+ ScheduleActivityTaskDecisionAttributes : & s.ScheduleActivityTaskDecisionAttributes {},
349+ },
350+ expected : & s.ScheduleActivityTaskDecisionAttributes {},
351+ },
352+ {
353+ decision : & s.Decision {
354+ DecisionType : toPtr (s .DecisionTypeRequestCancelActivityTask ),
355+ RequestCancelActivityTaskDecisionAttributes : & s.RequestCancelActivityTaskDecisionAttributes {},
356+ },
357+ expected : & s.RequestCancelActivityTaskDecisionAttributes {},
358+ },
359+ {
360+ decision : & s.Decision {
361+ DecisionType : toPtr (s .DecisionTypeStartTimer ),
362+ StartTimerDecisionAttributes : & s.StartTimerDecisionAttributes {},
363+ },
364+ expected : & s.StartTimerDecisionAttributes {},
365+ },
366+ {
367+ decision : & s.Decision {
368+ DecisionType : toPtr (s .DecisionTypeCancelTimer ),
369+ CancelTimerDecisionAttributes : & s.CancelTimerDecisionAttributes {},
370+ },
371+ expected : & s.CancelTimerDecisionAttributes {},
372+ },
373+ {
374+ decision : & s.Decision {
375+ DecisionType : toPtr (s .DecisionTypeCompleteWorkflowExecution ),
376+ CompleteWorkflowExecutionDecisionAttributes : & s.CompleteWorkflowExecutionDecisionAttributes {},
377+ },
378+ expected : & s.CompleteWorkflowExecutionDecisionAttributes {},
379+ },
380+ {
381+ decision : & s.Decision {
382+ DecisionType : toPtr (s .DecisionTypeFailWorkflowExecution ),
383+ FailWorkflowExecutionDecisionAttributes : & s.FailWorkflowExecutionDecisionAttributes {},
384+ },
385+ expected : & s.FailWorkflowExecutionDecisionAttributes {},
386+ },
387+ {
388+ decision : & s.Decision {
389+ DecisionType : toPtr (s .DecisionTypeRecordMarker ),
390+ RecordMarkerDecisionAttributes : & s.RecordMarkerDecisionAttributes {},
391+ },
392+ expected : & s.RecordMarkerDecisionAttributes {},
393+ },
394+ // In the default case, we should return the decision itself
395+ {
396+ decision : & s.Decision {
397+ DecisionType : toPtr (s .DecisionType (123456789 )),
398+ },
399+ expected : & s.Decision {
400+ DecisionType : toPtr (s .DecisionType (123456789 )),
401+ },
402+ },
403+ }
404+
405+ for _ , tc := range cases {
406+ name , err := tc .decision .GetDecisionType ().MarshalText ()
407+ require .NoError (t , err )
408+ t .Run (string (name ), func (t * testing.T ) {
409+ require .Equal (t , tc .expected , decisionGetData (tc .decision ))
320410 })
321411 }
322412}
0 commit comments