@@ -550,13 +550,13 @@ func (s sparam) LoadParam(ctx context.Context) (string, error) {
550
550
}
551
551
552
552
func TestShouldSupportStepParam (t * testing.T ) {
553
- var marshaller sparam
553
+ var sp sparam
554
554
555
555
fn := func (
556
556
ctx context.Context ,
557
557
a sparam ,
558
558
) {
559
- marshaller = a
559
+ sp = a
560
560
}
561
561
562
562
def := & models.StepDefinition {
@@ -569,7 +569,7 @@ func TestShouldSupportStepParam(t *testing.T) {
569
569
def .Args = []interface {}{"hello" }
570
570
_ , err := def .Run (context .Background ())
571
571
assert .Nil (t , err )
572
- assert .Equal (t , sparam ("hello world!" ), marshaller )
572
+ assert .Equal (t , sparam ("hello world!" ), sp )
573
573
}
574
574
575
575
type sparamptr string
@@ -579,13 +579,13 @@ func (s *sparamptr) LoadParam(ctx context.Context) (string, error) {
579
579
}
580
580
581
581
func TestShouldSupportStepParamPointerReceiver (t * testing.T ) {
582
- var marshaller sparamptr
582
+ var spptr sparamptr
583
583
584
584
fn := func (
585
585
ctx context.Context ,
586
586
a * sparamptr ,
587
587
) {
588
- marshaller = * a
588
+ spptr = * a
589
589
}
590
590
591
591
def := & models.StepDefinition {
@@ -598,7 +598,30 @@ func TestShouldSupportStepParamPointerReceiver(t *testing.T) {
598
598
def .Args = []interface {}{"hello" }
599
599
_ , err := def .Run (context .Background ())
600
600
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 ())
602
625
}
603
626
604
627
// this test is superficial compared to the ones above where the actual error messages the user woudl see are verified
0 commit comments