mu: update unit tests

They need to use 'mu init' as well.
This commit is contained in:
Dirk-Jan C. Binnema 2020-02-09 18:01:06 +02:00
parent 451309697d
commit 876f70d50d
5 changed files with 28 additions and 44 deletions

View File

@ -91,32 +91,6 @@ check_params (MuConfig *opts, GError **err)
return TRUE;
}
static gboolean
check_maildir (const char *maildir, GError **err)
{
if (!maildir) {
mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS,
"no maildir to work on; use --maildir=");
return FALSE;
}
if (!g_path_is_absolute (maildir)) {
mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS,
"maildir path '%s' is not absolute",
maildir);
return FALSE;
}
if (!mu_util_check_dir (maildir, TRUE, FALSE)) {
mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS,
"not a valid Maildir: %s", maildir);
return FALSE;
}
return TRUE;
}
static MuError
index_msg_silent_cb (MuIndexStats* stats, void *user_data)
{
@ -290,9 +264,6 @@ init_mu_index (MuStore *store, MuConfig *opts, GError **err)
if (!check_params (opts, err))
return NULL;
if (!check_maildir (opts->maildir, err))
return NULL;
midx = mu_index_new (store, err);
if (!midx)
return NULL;

View File

@ -40,10 +40,13 @@ fill_contacts_cache (void)
GError *err;
tmpdir = test_mu_common_get_random_tmpdir();
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
" --quiet",
MU_PROGRAM,
tmpdir, MU_TESTMAILDIR);
cmdline = g_strdup_printf (
"/bin/sh -c '"
"%s init --muhome=%s --maildir=%s --quiet; "
"%s index --muhome=%s --quiet'",
MU_PROGRAM, tmpdir, MU_TESTMAILDIR,
MU_PROGRAM, tmpdir);
if (g_test_verbose())
g_print ("%s\n", cmdline);

View File

@ -45,10 +45,12 @@ fill_database (void)
GError *err;
tmpdir = test_mu_common_get_random_tmpdir();
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
" --quiet",
MU_PROGRAM,
tmpdir, MU_TESTMAILDIR2);
cmdline = g_strdup_printf (
"/bin/sh -c '"
"%s init --muhome=%s --maildir=%s --quiet; "
"%s index --muhome=%s --quiet'",
MU_PROGRAM, tmpdir, MU_TESTMAILDIR2,
MU_PROGRAM, tmpdir);
if (g_test_verbose())
g_print ("%s\n", cmdline);
@ -118,7 +120,7 @@ test_mu_index (void)
gchar *xpath;
xpath = g_strdup_printf ("%s%c%s", DBPATH, G_DIR_SEPARATOR, "xapian");
g_printerr ("*** %s\n", DBPATH);
store = mu_store_new_readable (xpath, NULL);
g_assert (store);

View File

@ -45,9 +45,13 @@ fill_database (const char *testdir)
gchar *cmdline, *tmpdir, *xpath;
tmpdir = test_mu_common_get_random_tmpdir();
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
" --quiet",
MU_PROGRAM, tmpdir, testdir);
cmdline = g_strdup_printf (
"/bin/sh -c '"
"%s init --muhome=%s --maildir=%s --quiet ; "
"%s index --muhome=%s --quiet'",
MU_PROGRAM, tmpdir, testdir,
MU_PROGRAM, tmpdir);
if (g_test_verbose())
g_printerr ("\n%s\n", cmdline);

View File

@ -99,9 +99,13 @@ fill_database (const char *testdir)
gchar *cmdline, *tmpdir, *xpath;
tmpdir = test_mu_common_get_random_tmpdir();
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
" --quiet",
MU_PROGRAM, tmpdir, testdir);
cmdline = g_strdup_printf (
"/bin/sh -c '"
"%s init --muhome=%s --maildir=%s --quiet ; "
"%s index --muhome=%s --quiet'",
MU_PROGRAM, tmpdir, testdir,
MU_PROGRAM, tmpdir);
if (g_test_verbose())
g_print ("%s\n", cmdline);