@@ -434,6 +434,39 @@ func TestStandardSecrets(t *testing.T) {
434434 })
435435}
436436
437+ func TestStandardSecretsFailInNodeMode (t * testing.T ) {
438+ mockExecutionHelper := NewMockExecutionHelper (t )
439+ mockExecutionHelper .EXPECT ().GetWorkflowExecutionID ().Return ("id" )
440+ mockExecutionHelper .EXPECT ().GetNodeTime ().RunAndReturn (func () time.Time {
441+ return time .Now ()
442+ }).Maybe ()
443+ mockExecutionHelper .EXPECT ().GetDONTime ().RunAndReturn (func () (time.Time , error ) {
444+ return time .Now (), nil
445+ }).Maybe ()
446+ mockExecutionHelper .EXPECT ().CallCapability (mock .Anything , mock .Anything ).RunAndReturn (func (_ context.Context , request * sdk.CapabilityRequest ) (* sdk.CapabilityResponse , error ) {
447+ assert .Equal (t , "consensus@1.0.0-alpha" , request .Id )
448+ input := & sdk.SimpleConsensusInputs {}
449+ require .NoError (t , request .Payload .UnmarshalTo (input ))
450+
451+ var errMsg string
452+ switch msg := input .Observation .(type ) {
453+ case * sdk.SimpleConsensusInputs_Error :
454+ errMsg = msg .Error
455+ default :
456+ require .Fail (t , "observation must be an error" )
457+ }
458+ return & sdk.CapabilityResponse {
459+ Response : & sdk.CapabilityResponse_Error {Error : errMsg },
460+ }, nil
461+ }).Once ()
462+ m := makeTestModule (t )
463+ request := triggerExecuteRequest (t , 0 , & basictrigger.Outputs {CoolOutput : anyTestTriggerValue })
464+
465+ errStr := executeWithError (t , m , request , mockExecutionHelper )
466+
467+ require .Contains (t , errStr , "cannot use Runtime inside RunInNodeMode" )
468+ }
469+
437470func triggerExecuteRequest (t * testing.T , id uint64 , trigger proto.Message ) * sdk.ExecuteRequest {
438471 wrappedTrigger , err := anypb .New (trigger )
439472 require .NoError (t , err )
0 commit comments