geary/test/engine/imap/command/imap-create-command-test.vala
Michael Gratton 85e9046c71 Geary.Imap: Make command cancellable a property of the command object
Since both submitting a command no longer requires a cancellable, and it
is desirable to avoid sending a queued command that has already been
cancelled beforehand, add a new `Command.should_send` Cancellable
property to specify if a command should (still) be sent or not, and stop
passing a cancellable to ClientSession when submitting commands.

Allow call sites to pass in existing cancellable objects, and thus also
add it it as a ctor property to the Command class and all subclasses.

Lastly, throw a cancelled exception in `wait_until_complete` if send
was cancelled so that the caller knows what happened.

Remove redundant cancellable argument from
`Imap.Client.command_transaction_async` and rename it to
`submit_command` to make it more obvious about what it does.
2020-09-02 14:34:41 +10:00

35 lines
952 B
Vala

/*
* Copyright 2017 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.Imap.CreateCommandTest : TestCase {
public CreateCommandTest() {
base("Geary.Imap.CreateCommandTest");
add_test("basic_create", basic_create);
add_test("special_use", special_use);
}
public void basic_create() throws Error {
assert_equal(
new CreateCommand(new MailboxSpecifier("owatagusiam/"), null).to_string(),
"---- create owatagusiam/"
);
}
public void special_use() throws Error {
assert_equal(
new CreateCommand.special_use(
new MailboxSpecifier("Everything"),
ALL_MAIL,
null
).to_string(),
"---- create Everything (use (\\All))"
);
}
}