anchor.diff:      DbName = ?tempdb(),
       {ok, _} = couch_db:create(DbName, [?ADMIN_USER]),
       FooRev = create_design_doc(DbName, <<"_design/foo">>, <<"bar">>),
  -    ok = query_view(DbName, "foo", "bar"),
  +    query_view(DbName, "foo", "bar"),
       BooRev = create_design_doc(DbName, <<"_design/boo">>, <<"baz">>),
  -    ok = query_view(DbName, "boo", "baz"),
  +    query_view(DbName, "boo", "baz"),
       {DbName, {FooRev, BooRev}}.
   
  +setup_with_docs() ->
  +    DbName = ?tempdb(),
  +    {ok, _} = couch_db:create(DbName, [?ADMIN_USER]),
  +    create_docs(DbName),
  +    create_design_doc(DbName, <<"_design/foo">>, <<"bar">>),
  +    DbName.
  +
   teardown({DbName, _}) ->
  -    ok = couch_server:delete(DbName, []),
  +    teardown(DbName);
  +teardown(DbName) when is_binary(DbName) ->
  +    ok = couch_server:delete(DbName, [?ADMIN_USER]),
       ok.
   
   
  
positive.code: db_url(DbName) ->
      Addr = couch_config:get("httpd", "bind_address", "127.0.0.1"),
      Port = integer_to_list(mochiweb_socket_server:get(couch_httpd, port)),
      "http://" ++ Addr ++ ":" ++ Port ++ "/" ++ binary_to_list(DbName).
  
  query_view(DbName, DDoc, View) ->
      {ok, Code, _Headers, _Body} = test_request:get(
          db_url(DbName) ++ "/_design/" ++ DDoc ++ "/_view/" ++ View),
      ?assertEqual(200, Code),
      ok.
  
  view_cleanup(DbName) ->
      {ok, Db} = couch_db:open(DbName, [?ADMIN_USER]),
  
negative.code:     RootDir = couch_config:get("couchdb", "view_index_dir"),
      length(filelib:wildcard(RootDir ++ "/." ++
          binary_to_list(DbName) ++ "_design"++"/mrview/*")).
  
  has_doc(DocId1, Rows) ->
      DocId = iolist_to_binary(DocId1),
      lists:any(fun({R}) -> lists:member({<<"id">>, DocId}, R) end, Rows).
  
  backup_db_file(DbName) ->
      DbDir = couch_config:get("couchdb", "database_dir"),
      DbFile = filename:join([DbDir, ?b2l(DbName) ++ ".couch"]),
      {ok, _} = file:copy(DbFile, DbFile ++ ".backup"),
      ok.
  
  restore_backup_db_file(DbName) ->
      DbDir = couch_config:get("couchdb", "database_dir"),
      stop(whereis(couch_server_sup)),
      DbFile = filename:join([DbDir, ?b2l(DbName) ++ ".couch"]),
      ok = file:delete(DbFile),
      ok = file:rename(DbFile ++ ".backup", DbFile),
      start(),
      ok.
  