tonysun83 commented on a change in pull request #1067: Fix mango native proc 
crash
URL: https://github.com/apache/couchdb/pull/1067#discussion_r158113541
 
 

 ##########
 File path: src/mango/src/mango_native_proc.erl
 ##########
 @@ -363,4 +366,35 @@ validate_index_info(IndexInfo) ->
             [invalid_index | Results0]
         end
     end, [], IdxTypes),
-    lists:member(valid_index, Results).
\ No newline at end of file
+    lists:member(valid_index, Results).
+
+
+-ifdef(TEST).
+
+-include_lib("eunit/include/eunit.hrl").
+
+handle_garbage_collect_cast_test() ->
+    Pid = self(),
+    {_, TracerRef} = spawn_monitor(fun() ->
+        erlang:trace(Pid, true, [garbage_collection]),
+        receive {trace, Pid, gc_start, _} ->
+            erlang:trace(Pid, false, [garbage_collection]),
+            exit(gc_start)
+        end
+    end),
+    erlang:yield(),
+    ?assertEqual({noreply, []}, handle_cast(garbage_collect, [])),
+    receive
+        {'DOWN', TracerRef, _, _, Msg} -> ?assertEqual(gc_start, Msg)
 
 Review comment:
   @eiri : I completely forgot to check that we have 
```handle_cast(garbage_collect, St)```  in the source. That's what confused me. 
This test was for that functionality. Got it!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to