anchor.diff:         end},
         {"chef_index_batch flushes an added item automatically",
          fun() ->
  +               meck:expect(chef_index_expand, post_to_solr, fun(_Payload) -> ok end),
                  application:set_env(chef_index, search_batch_max_wait, 10),
                  restart_server(),
  -               meck:expect(chef_index_expand, post_to_solr, fun(_Payload) -> ok end),
                  add_item(<<"abcdefg">>),
                  ?assertEqual(ok, wait_for_res())
          end
         },
         {"chef_index_batch flushes when current_size+wrapper_size >= max_size",
          fun() ->
  +               meck:expect(chef_index_expand, post_to_solr, fun(_Payload) -> ok end),
                  application:set_env(chef_index, search_batch_max_size, 70),
                  restart_server(),
  -               meck:expect(chef_index_expand, post_to_solr, fun(_Payload) -> ok end),
                  add_item(<<"abcd">>), % The wrapper size is 66
                  ?assertEqual(ok, wait_for_res())
          end
  
positive.code:      ]
      }.
  
  restart_server() ->
      chef_index_batch:stop(),
      chef_index_batch:start_link().
  
  add_item(Item) ->
      Us = self(),
      spawn(fun() ->
                    erlang:send(Us, started),
                    Res = chef_index_batch:add_item(Item),
                    erlang:send(Us, Res)
            end),
      wait_for_started().
  
  
negative.code:      end,
       fun(_Pid) ->
               meck:unload(chef_index_expand),
               stop_server()
       end,
       [{"current_size+wrapper_size is the actual size posted to solr",
         fun() ->
  