jiahuili430 commented on a change in pull request #3779:
URL: https://github.com/apache/couchdb/pull/3779#discussion_r725669946



##########
File path: src/fabric/test/eunit/fabric_tests.erl
##########
@@ -0,0 +1,67 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(fabric_tests).
+
+
+-include_lib("couch/include/couch_eunit.hrl").
+
+
+cleanup_index_files_test_() ->
+  {
+    setup,
+    fun setup/0,
+    fun teardown/1,
+    fun(Ctx) -> [
+      test_cleanup_index_files(),
+      test_cleanup_index_files_with_existing_db(Ctx),
+      test_cleanup_index_files_with_deleted_db(Ctx)
+    ] end
+  }.
+
+
+setup() ->
+  test_util:start_couch([fabric]),
+  meck:new(fabric, [passthrough]),
+  DbName = ?tempdb(),
+  fabric:create_db(DbName),
+  mock_inactive_index_files(DbName),
+  DbName.
+
+
+teardown(Ctx) ->
+  meck:unload(),
+  test_util:stop_couch(Ctx).
+
+
+mock_inactive_index_files(_) ->
+  meck:expect(fabric, inactive_index_files, fun(_) -> [] end).
+
+
+test_cleanup_index_files() ->
+  ?_assertMatch([ok | _], fabric:cleanup_index_files()).

Review comment:
       `cleanup_index_files()` will use `fabric:all_dbs()`, I am not sure how 
many databases are created by the CI test, so I use `assertMatch([ok | _], 
...)` here.
   ```
   module 'fabric'
   [2021-10-10T01:51:11.748Z]   module 'fabric_tests'
   [2021-10-10T01:51:13.495Z]     fabric_tests:44: 
test_cleanup_index_files...*failed*
   [2021-10-10T01:51:13.495Z] in function 
fabric_tests:'-test_cleanup_index_files/0-fun-0-'/0 
(test/eunit/fabric_tests.erl, line 44)
   [2021-10-10T01:51:13.495Z] in call from eunit_test:run_testfun/1 
(eunit_test.erl, line 71)
   [2021-10-10T01:51:13.495Z] in call from eunit_proc:run_test/1 
(eunit_proc.erl, line 510)
   [2021-10-10T01:51:13.495Z] in call from eunit_proc:with_timeout/3 
(eunit_proc.erl, line 335)
   [2021-10-10T01:51:13.495Z] in call from eunit_proc:handle_test/2 
(eunit_proc.erl, line 493)
   [2021-10-10T01:51:13.495Z] in call from eunit_proc:tests_inorder/3 
(eunit_proc.erl, line 435)
   [2021-10-10T01:51:13.495Z] in call from eunit_proc:with_timeout/3 
(eunit_proc.erl, line 325)
   [2021-10-10T01:51:13.495Z] in call from eunit_proc:run_group/2 
(eunit_proc.erl, line 549)
   [2021-10-10T01:51:13.495Z] **error:{assertMatch,[{module,fabric_tests},
   [2021-10-10T01:51:13.495Z]               {line,44},
   [2021-10-10T01:51:13.495Z]               {expression,"fabric : 
cleanup_index_files ( )"},
   [2021-10-10T01:51:13.495Z]               {pattern,"[ ok ]"},
   [2021-10-10T01:51:13.495Z]               
{value,[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok|...]}]}
   [2021-10-10T01:51:13.495Z]   output:<<"">>
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to