2019-01-14 11:01:03 +11:00
|
|
|
/*
|
|
|
|
|
* Copyright 2019 Michael Gratton <mike@vee.net>
|
|
|
|
|
*
|
|
|
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
|
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Geary.ImapDB.AccountTest : TestCase {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GLib.File? tmp_dir = null;
|
|
|
|
|
private Geary.AccountInformation? config = null;
|
|
|
|
|
private Account? account = null;
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
private FolderRoot? root = null;
|
2019-01-14 11:01:03 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public AccountTest() {
|
|
|
|
|
base("Geary.ImapDB.AccountTest");
|
|
|
|
|
add_test("create_base_folder", create_base_folder);
|
|
|
|
|
add_test("create_child_folder", create_child_folder);
|
|
|
|
|
add_test("list_folders", list_folders);
|
|
|
|
|
add_test("delete_folder", delete_folder);
|
|
|
|
|
add_test("delete_folder_with_child", delete_folder_with_child);
|
|
|
|
|
add_test("delete_nonexistent_folder", delete_nonexistent_folder);
|
|
|
|
|
add_test("fetch_base_folder", fetch_base_folder);
|
|
|
|
|
add_test("fetch_child_folder", fetch_child_folder);
|
|
|
|
|
add_test("fetch_nonexistent_folder", fetch_nonexistent_folder);
|
2019-12-10 13:36:36 +11:00
|
|
|
add_test("list_local_email", list_local_email);
|
2019-01-14 11:01:03 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void set_up() throws GLib.Error {
|
|
|
|
|
this.tmp_dir = GLib.File.new_for_path(
|
2019-01-22 00:55:38 +11:00
|
|
|
GLib.DirUtils.make_tmp("geary-imap-db-account-test-XXXXXX")
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.config = new Geary.AccountInformation(
|
|
|
|
|
"test",
|
|
|
|
|
ServiceProvider.OTHER,
|
2020-08-10 16:13:57 +10:00
|
|
|
new Mock.CredentialsMediator(),
|
2019-01-14 11:01:03 +11:00
|
|
|
new Geary.RFC822.MailboxAddress(null, "test@example.com")
|
|
|
|
|
);
|
|
|
|
|
|
2019-06-12 07:31:51 +10:00
|
|
|
this.account = new Account(
|
|
|
|
|
config,
|
2019-01-14 11:01:03 +11:00
|
|
|
this.tmp_dir,
|
2025-12-07 01:21:41 +01:00
|
|
|
GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql")
|
2019-06-12 07:31:51 +10:00
|
|
|
);
|
|
|
|
|
this.account.open_async.begin(
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
this.account.open_async.end(async_result());
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
|
2019-04-14 20:55:42 +10:00
|
|
|
this.root = new FolderRoot("#test", false);
|
2019-01-14 11:01:03 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void tear_down() throws GLib.Error {
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root = null;
|
2019-01-14 11:01:03 +11:00
|
|
|
this.account.close_async.begin(
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
this.account.close_async.end(async_result());
|
2019-01-22 01:45:02 +11:00
|
|
|
this.account = null;
|
2019-02-08 10:13:49 +11:00
|
|
|
this.config = null;
|
2019-01-14 11:01:03 +11:00
|
|
|
|
|
|
|
|
delete_file(this.tmp_dir);
|
|
|
|
|
this.tmp_dir = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void create_base_folder() throws GLib.Error {
|
|
|
|
|
Imap.Folder folder = new Imap.Folder(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test"),
|
2019-01-14 11:01:03 +11:00
|
|
|
new Imap.FolderProperties.selectable(
|
|
|
|
|
new Imap.MailboxAttributes(
|
|
|
|
|
Gee.Collection.empty<Geary.Imap.MailboxAttribute>()
|
|
|
|
|
),
|
|
|
|
|
new Imap.StatusData(
|
|
|
|
|
new Imap.MailboxSpecifier("test"),
|
|
|
|
|
10, // total
|
|
|
|
|
9, // recent
|
|
|
|
|
new Imap.UID(8),
|
|
|
|
|
new Imap.UIDValidity(7),
|
|
|
|
|
6 //unseen
|
|
|
|
|
),
|
2019-12-29 23:15:34 +10:30
|
|
|
new Imap.Capabilities.empty(0)
|
2019-01-14 11:01:03 +11:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.account.clone_folder_async.begin(
|
|
|
|
|
folder,
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
this.account.clone_folder_async.end(async_result());
|
|
|
|
|
|
|
|
|
|
Geary.Db.Result result = this.account.db.query(
|
|
|
|
|
"SELECT * FROM FolderTable;"
|
|
|
|
|
);
|
|
|
|
|
assert_false(result.finished, "Folder not created");
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal(result.string_for("name"), "test", "Folder name");
|
2019-01-14 11:01:03 +11:00
|
|
|
assert_true(result.is_null_for("parent_id"), "Folder parent");
|
|
|
|
|
assert_false(result.next(), "Multiple rows inserted");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void create_child_folder() throws GLib.Error {
|
|
|
|
|
this.account.db.exec(
|
|
|
|
|
"INSERT INTO FolderTable (id, name) VALUES (1, 'test');"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Imap.Folder folder = new Imap.Folder(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test").get_child("child"),
|
2019-01-14 11:01:03 +11:00
|
|
|
new Imap.FolderProperties.selectable(
|
|
|
|
|
new Imap.MailboxAttributes(
|
|
|
|
|
Gee.Collection.empty<Geary.Imap.MailboxAttribute>()
|
|
|
|
|
),
|
|
|
|
|
new Imap.StatusData(
|
|
|
|
|
new Imap.MailboxSpecifier("test>child"),
|
|
|
|
|
10, // total
|
|
|
|
|
9, // recent
|
|
|
|
|
new Imap.UID(8),
|
|
|
|
|
new Imap.UIDValidity(7),
|
|
|
|
|
6 //unseen
|
|
|
|
|
),
|
2019-12-29 23:15:34 +10:30
|
|
|
new Imap.Capabilities.empty(0)
|
2019-01-14 11:01:03 +11:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.account.clone_folder_async.begin(
|
|
|
|
|
folder,
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
this.account.clone_folder_async.end(async_result());
|
|
|
|
|
|
|
|
|
|
Geary.Db.Result result = this.account.db.query(
|
|
|
|
|
"SELECT * FROM FolderTable WHERE id != 1;"
|
|
|
|
|
);
|
|
|
|
|
assert_false(result.finished, "Folder not created");
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal(result.string_for("name"), "child", "Folder name");
|
|
|
|
|
assert_equal<int?>(result.int_for("parent_id"), 1, "Folder parent");
|
2019-01-14 11:01:03 +11:00
|
|
|
assert_false(result.next(), "Multiple rows inserted");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void list_folders() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1),
|
|
|
|
|
(3, 'test3', 2);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.list_folders_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.account.imap_folder_root,
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
Gee.Collection<Geary.ImapDB.Folder> result =
|
|
|
|
|
this.account.list_folders_async.end(async_result());
|
|
|
|
|
|
|
|
|
|
Folder test1 = traverse(result).first();
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal<int?>(result.size, 1, "Base folder not listed");
|
|
|
|
|
assert_equal(test1.get_path().name, "test1", "Base folder name");
|
2019-01-14 11:01:03 +11:00
|
|
|
|
|
|
|
|
this.account.list_folders_async.begin(
|
|
|
|
|
test1.get_path(),
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
result = this.account.list_folders_async.end(async_result());
|
|
|
|
|
|
|
|
|
|
Folder test2 = traverse(result).first();
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal<int?>(result.size, 1, "Child folder not listed");
|
|
|
|
|
assert_equal(test2.get_path().name, "test2", "Child folder name");
|
2019-01-14 11:01:03 +11:00
|
|
|
|
|
|
|
|
this.account.list_folders_async.begin(
|
|
|
|
|
test2.get_path(),
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
result = this.account.list_folders_async.end(async_result());
|
|
|
|
|
|
|
|
|
|
Folder test3 = traverse(result).first();
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal<int?>(result.size, 1, "Grandchild folder not listed");
|
|
|
|
|
assert_equal(test3.get_path().name, "test3", "Grandchild folder name");
|
2019-01-14 11:01:03 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delete_folder() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.delete_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test1").get_child("test2"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
this.account.delete_folder_async.end(async_result());
|
|
|
|
|
|
|
|
|
|
this.account.delete_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test1"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
this.account.delete_folder_async.end(async_result());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delete_folder_with_child() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.delete_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test1"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
try {
|
|
|
|
|
this.account.delete_folder_async.end(async_result());
|
|
|
|
|
assert_not_reached();
|
|
|
|
|
} catch (GLib.Error err) {
|
|
|
|
|
assert_error(new ImapError.NOT_SUPPORTED(""), err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delete_nonexistent_folder() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.delete_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test3"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
try {
|
|
|
|
|
this.account.delete_folder_async.end(async_result());
|
|
|
|
|
assert_not_reached();
|
|
|
|
|
} catch (GLib.Error err) {
|
|
|
|
|
assert_error(new EngineError.NOT_FOUND(""), err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fetch_base_folder() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.fetch_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test1"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Folder? result = this.account.fetch_folder_async.end(async_result());
|
|
|
|
|
assert_non_null(result);
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal(result.get_path().name, "test1");
|
2019-01-14 11:01:03 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fetch_child_folder() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.fetch_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test1").get_child("test2"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Folder? result = this.account.fetch_folder_async.end(async_result());
|
|
|
|
|
assert_non_null(result);
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal(result.get_path().name, "test2");
|
2019-01-14 11:01:03 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fetch_nonexistent_folder() throws GLib.Error {
|
|
|
|
|
this.account.db.exec("""
|
|
|
|
|
INSERT INTO FolderTable (id, name, parent_id)
|
|
|
|
|
VALUES
|
|
|
|
|
(1, 'test1', null),
|
|
|
|
|
(2, 'test2', 1);
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
this.account.fetch_folder_async.begin(
|
Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-14 12:10:48 +11:00
|
|
|
this.root.get_child("test3"),
|
2019-01-14 11:01:03 +11:00
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-01-14 11:01:03 +11:00
|
|
|
);
|
|
|
|
|
try {
|
|
|
|
|
this.account.fetch_folder_async.end(async_result());
|
|
|
|
|
assert_not_reached();
|
|
|
|
|
} catch (GLib.Error err) {
|
|
|
|
|
assert_error(new EngineError.NOT_FOUND(""), err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 13:36:36 +11:00
|
|
|
public void list_local_email() throws GLib.Error {
|
|
|
|
|
Email.Field fixture_fields = Email.Field.RECEIVERS;
|
|
|
|
|
string fixture_to = "test1@example.com";
|
|
|
|
|
this.account.db.exec(
|
|
|
|
|
"INSERT INTO MessageTable (id, fields, to_field) " +
|
|
|
|
|
"VALUES (1, %d, '%s');".printf(fixture_fields, fixture_to)
|
|
|
|
|
);
|
|
|
|
|
this.account.db.exec(
|
|
|
|
|
"INSERT INTO MessageTable (id, fields, to_field) " +
|
|
|
|
|
"VALUES (2, %d, '%s');".printf(fixture_fields, fixture_to)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.account.list_email.begin(
|
|
|
|
|
iterate_array<Geary.ImapDB.EmailIdentifier>({
|
|
|
|
|
new EmailIdentifier(1, null),
|
|
|
|
|
new EmailIdentifier(2, null)
|
|
|
|
|
}).to_linked_list(),
|
|
|
|
|
Email.Field.RECEIVERS,
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-12-10 13:36:36 +11:00
|
|
|
);
|
|
|
|
|
Gee.List<Email> result = this.account.list_email.end(
|
|
|
|
|
async_result()
|
|
|
|
|
);
|
|
|
|
|
|
2020-05-09 16:04:22 +10:00
|
|
|
assert_equal<int?>(result.size, 2, "Not enough email listed");
|
2019-12-10 13:36:36 +11:00
|
|
|
assert_true(new EmailIdentifier(1, null).equal_to(result[0].id));
|
|
|
|
|
assert_true(new EmailIdentifier(2, null).equal_to(result[1].id));
|
|
|
|
|
|
|
|
|
|
this.account.list_email.begin(
|
|
|
|
|
Collection.single(new EmailIdentifier(3, null)),
|
|
|
|
|
Email.Field.RECEIVERS,
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-12-10 13:36:36 +11:00
|
|
|
);
|
|
|
|
|
try {
|
|
|
|
|
this.account.list_email.end(async_result());
|
|
|
|
|
assert_not_reached();
|
|
|
|
|
} catch (EngineError.NOT_FOUND error) {
|
|
|
|
|
// All good
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.account.list_email.begin(
|
|
|
|
|
Collection.single(new EmailIdentifier(1, null)),
|
|
|
|
|
Email.Field.BODY,
|
|
|
|
|
null,
|
2020-04-10 12:58:09 +10:00
|
|
|
this.async_completion
|
2019-12-10 13:36:36 +11:00
|
|
|
);
|
|
|
|
|
try {
|
|
|
|
|
this.account.list_email.end(async_result());
|
|
|
|
|
assert_not_reached();
|
|
|
|
|
} catch (EngineError.INCOMPLETE_MESSAGE error) {
|
|
|
|
|
// All good
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 11:01:03 +11:00
|
|
|
}
|