@@ -2821,6 +2821,30 @@ func TestV1Beta1Workflow(t *testing.T) {
2821
2821
assert .Nil (t , resp .ErrorBody )
2822
2822
})
2823
2823
2824
+ t .Run ("Terminate with non_recursive set to false" , func (t * testing.T ) {
2825
+ // This has the same behavior as the case when non_recursive parameter is not set.
2826
+ // This is because default case is set to recursive termination.
2827
+
2828
+ apiPath := "v1.0-beta1/workflows/dapr/instanceID/terminate?non_recursive=false"
2829
+
2830
+ resp := fakeServer .DoRequest ("POST" , apiPath , nil , nil )
2831
+ assert .Equal (t , 202 , resp .StatusCode )
2832
+
2833
+ // assert
2834
+ assert .Nil (t , resp .ErrorBody )
2835
+ })
2836
+
2837
+ t .Run ("Terminate with non_recursive true" , func (t * testing.T ) {
2838
+ // Note that in case of non_recursive true, MockWorkflow intentionally returns fake error, even when it is not an actual error.
2839
+ // This is to test that non_recursive flag is being passed correctly to the workflow component.
2840
+
2841
+ apiPath := "v1.0-beta1/workflows/dapr/instanceID/terminate?non_recursive=true"
2842
+ resp := fakeServer .DoRequest ("POST" , apiPath , nil , nil )
2843
+ assert .Equal (t , 500 , resp .StatusCode )
2844
+ assert .Equal (t , "ERR_TERMINATE_WORKFLOW" , resp .ErrorBody ["errorCode" ])
2845
+ assert .Equal (t , fmt .Sprintf (messages .ErrTerminateWorkflow .Message (), "instanceID" , daprt .ErrFakeWorkflowNonRecursiveTerminateError ), resp .ErrorBody ["message" ])
2846
+ })
2847
+
2824
2848
///////////////////////////
2825
2849
// RAISE EVENT API TESTS //
2826
2850
///////////////////////////
@@ -2931,6 +2955,28 @@ func TestV1Beta1Workflow(t *testing.T) {
2931
2955
// assert
2932
2956
assert .Nil (t , resp .ErrorBody )
2933
2957
})
2958
+
2959
+ t .Run ("Purge with non_recursive false" , func (t * testing.T ) {
2960
+ // This has the same behavior as the case when non_recursive parameter is not set.
2961
+ // This is because default case is set to recursive purge.
2962
+
2963
+ apiPath := "v1.0-beta1/workflows/dapr/instanceID/purge?non_recursive=false"
2964
+ resp := fakeServer .DoRequest ("POST" , apiPath , nil , nil )
2965
+ assert .Equal (t , 202 , resp .StatusCode )
2966
+
2967
+ // assert
2968
+ assert .Nil (t , resp .ErrorBody )
2969
+ })
2970
+ t .Run ("Purge with non_recursive true" , func (t * testing.T ) {
2971
+ // Note that in case of non_recursive true, MockWorkflow intentionally returns fake error, even when it is not an actual error.
2972
+ // This is to test that non_recursive flag is being passed correctly to the workflow component.
2973
+
2974
+ apiPath := "v1.0-beta1/workflows/dapr/instanceID/purge?non_recursive=true"
2975
+ resp := fakeServer .DoRequest ("POST" , apiPath , nil , nil )
2976
+ assert .Equal (t , 500 , resp .StatusCode )
2977
+ assert .Equal (t , "ERR_PURGE_WORKFLOW" , resp .ErrorBody ["errorCode" ])
2978
+ assert .Equal (t , fmt .Sprintf (messages .ErrPurgeWorkflow .Message (), "instanceID" , daprt .ErrFakeWorkflowNonRecurisvePurgeError ), resp .ErrorBody ["message" ])
2979
+ })
2934
2980
}
2935
2981
2936
2982
func buildHTTPPineline (spec config.PipelineSpec ) httpMiddleware.Pipeline {
0 commit comments