@@ -550,13 +550,13 @@ func (s sparam) LoadParam(ctx context.Context) (string, error) {
550550}
551551
552552func TestShouldSupportStepParam (t * testing.T ) {
553- var marshaller sparam
553+ var sp sparam
554554
555555 fn := func (
556556 ctx context.Context ,
557557 a sparam ,
558558 ) {
559- marshaller = a
559+ sp = a
560560 }
561561
562562 def := & models.StepDefinition {
@@ -569,7 +569,7 @@ func TestShouldSupportStepParam(t *testing.T) {
569569 def .Args = []interface {}{"hello" }
570570 _ , err := def .Run (context .Background ())
571571 assert .Nil (t , err )
572- assert .Equal (t , sparam ("hello world!" ), marshaller )
572+ assert .Equal (t , sparam ("hello world!" ), sp )
573573}
574574
575575type sparamptr string
@@ -579,13 +579,13 @@ func (s *sparamptr) LoadParam(ctx context.Context) (string, error) {
579579}
580580
581581func TestShouldSupportStepParamPointerReceiver (t * testing.T ) {
582- var marshaller sparamptr
582+ var spptr sparamptr
583583
584584 fn := func (
585585 ctx context.Context ,
586586 a * sparamptr ,
587587 ) {
588- marshaller = * a
588+ spptr = * a
589589 }
590590
591591 def := & models.StepDefinition {
@@ -598,7 +598,30 @@ func TestShouldSupportStepParamPointerReceiver(t *testing.T) {
598598 def .Args = []interface {}{"hello" }
599599 _ , err := def .Run (context .Background ())
600600 assert .Nil (t , err )
601- assert .Equal (t , sparamptr ("hello world!" ), marshaller )
601+ assert .Equal (t , sparamptr ("hello world!" ), spptr )
602+ }
603+
604+ type sparamerr string
605+
606+ func (s sparamerr ) LoadParam (context.Context ) (string , error ) {
607+ return "" , errors .New ("oh no" )
608+ }
609+
610+ func TestShouldSupportStepParamErrorOnLoad (t * testing.T ) {
611+ expectedError := errors .New ("failed to load param for arg[0]: oh no" )
612+
613+ fn := func (ctx context.Context , s sparamerr ) {}
614+
615+ def := & models.StepDefinition {
616+ StepDefinition : formatters.StepDefinition {
617+ Handler : fn ,
618+ },
619+ HandlerValue : reflect .ValueOf (fn ),
620+ }
621+
622+ def .Args = []interface {}{"hello" }
623+ _ , err := def .Run (context .Background ())
624+ assert .Equal (t , expectedError .Error (), err .(error ).Error ())
602625}
603626
604627// this test is superficial compared to the ones above where the actual error messages the user woudl see are verified
0 commit comments