unit tests: improve

and add a new one for the indexer
This commit is contained in:
Dirk-Jan C. Binnema
2023-09-12 19:30:18 +03:00
parent 805c5aa287
commit 2f5602b938
14 changed files with 149 additions and 123 deletions

View File

@ -1,4 +1,4 @@
## Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2021-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by

View File

@ -1,69 +0,0 @@
/*
** Copyright (C) 2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
#include <vector>
#include <glib.h>
#include <iostream>
#include <sstream>
#include <unistd.h>
#include "mu-indexer.hh"
#include "utils/mu-utils.hh"
#include "test-mu-common.h"
using namespace Mu;
static void
test_index_maildir()
{
allow_warnings();
Store store{test_mu_common_get_random_tmpdir(), std::string{MU_TESTMAILDIR}};
Indexer idx{Indexer::Config{}, store};
g_assert_true(idx.start());
while (idx.is_running()) {
sleep(1);
}
g_print("again!\n");
g_assert_true(idx.start());
while (idx.is_running()) {
sleep(1);
}
}
int
main(int argc, char* argv[])
try {
g_test_init(&argc, &argv, NULL);
g_test_add_func("/indexer/index-maildir", test_index_maildir);
return g_test_run();
} catch (const std::runtime_error& re) {
std::cerr << re.what() << "\n";
return 1;
} catch (...) {
std::cerr << "caught exception\n";
return 1;
}

View File

@ -45,7 +45,7 @@ static Store
make_test_store(const std::string& test_path, const TestMap& test_map,
Option<const Config&> conf={})
{
std::string maildir = test_path + "/Maildir/";
const auto maildir{join_paths(test_path, "/Maildir/")};
// note the trailing '/'
g_test_bug("2513");
@ -819,7 +819,7 @@ html
static void
test_cjk()
test_ngrams()
{
g_test_bug("2167");
@ -882,9 +882,8 @@ main(int argc, char* argv[])
{
mu_test_init(&argc, &argv);
//_test_add_func("/store/query/cjk", test_cjk);
g_test_add_func("/store/query/simple", test_simple);
g_test_add_func("/store/query/simple",
test_simple);
g_test_add_func("/store/query/spam-address-components",
test_spam_address_components);
g_test_add_func("/store/query/dups-related",
@ -905,9 +904,8 @@ main(int argc, char* argv[])
test_related_dup_threaded);
g_test_add_func("/store/query/html",
test_html);
g_test_add_func("/store/query/cjk-once-more", test_cjk);
g_test_add_func("/store/query/ngrams",
test_ngrams);
return g_test_run();
}