about summary refs log tree commit diff stats
path: root/vimrc.vim
Commit message (Collapse)AuthorAgeFilesLines
* 5856Kartik Agaram2020-01-011-9/+1
|
* 5758Kartik Agaram2019-11-251-5/+2
|
* 5749Kartik Agaram2019-11-171-1/+1
| | | | | Support running a single test when the current function around the cursor ends in '?'.
* 5662Kartik Agaram2019-09-151-2/+2
| | | | Fix several breakages.
* 5643Kartik Agaram2019-09-081-9/+5
|
* 5642Kartik Agaram2019-09-071-1/+1
|
* 5641Kartik Agaram2019-09-071-8/+0
|
* 5640Kartik Agaram2019-09-071-3/+6
|
* 5639 - tmux support for running a single testKartik Agaram2019-09-071-18/+35
| | | | | | | | Keep the top/left most pane for a shell, and try hitting `<Leader>t` from within a test. If you hit `<Leader>t` from within code, it will try to remember what test you ran last and rerun that.
* 5618Kartik Agaram2019-09-041-0/+2
|
* 5617Kartik Agaram2019-09-041-3/+0
|
* 5509Kartik Agaram2019-08-111-2/+2
|
* 5499Kartik Agaram2019-07-311-1/+0
|
* 5489 - fix a few broken linksKartik Agaram2019-07-271-1/+1
|
* 5485 - promote SubX to top-levelKartik Agaram2019-07-271-1/+76
|
* fork vimrc for Mu and SubXKartik Agaram2019-06-111-64/+0
| | | | | I checked if we needed to bring back anything since commit 3976, but the only difference is dropping the :(scenario) DSL.
* only open the trace if test failsKartik Agaram2019-06-111-2/+16
|
* new Vim convenience macroKartik Agaram2019-06-111-0/+3
| | | | Runs test under cursor and opens its trace.
* .Kartik Agaram2019-05-151-1/+1
|
* 5079Kartik Agaram2019-04-111-13/+2
|
* 5001 - drop the :(scenario) DSLKartik Agaram2019-03-121-23/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've been saying for a while[1][2][3] that adding extra abstractions makes things harder for newcomers, and adding new notations doubly so. And then I notice this DSL in my own backyard. Makes me feel like a hypocrite. [1] https://news.ycombinator.com/item?id=13565743#13570092 [2] https://lobste.rs/s/to8wpr/configuration_files_are_canary_warning [3] https://lobste.rs/s/mdmcdi/little_languages_by_jon_bentley_1986#c_3miuf2 The implementation of the DSL was also highly hacky: a) It was happening in the tangle/ tool, but was utterly unrelated to tangling layers. b) There were several persnickety constraints on the different kinds of lines and the specific order they were expected in. I kept finding bugs where the translator would silently do the wrong thing. Or the error messages sucked, and readers may be stuck looking at the generated code to figure out what happened. Fixing error messages would require a lot more code, which is one of my arguments against DSLs in the first place: they may be easy to implement, but they're hard to design to go with the grain of the underlying platform. They require lots of iteration. Is that effort worth prioritizing in this project? On the other hand, the DSL did make at least some readers' life easier, the ones who weren't immediately put off by having to learn a strange syntax. There were fewer quotes to parse, fewer backslash escapes. Anyway, since there are also people who dislike having to put up with strange syntaxes, we'll call that consideration a wash and tear this DSL out. --- This commit was sheer drudgery. Hopefully it won't need to be redone with a new DSL because I grow sick of backslashes.
* 4985Kartik Agaram2019-02-231-0/+5
|
* 4875Kartik Agaram2018-12-251-1/+3
| | | | Another tweak for a light background.
* 4806Kartik Agaram2018-11-301-2/+2
| | | | | | Drop a wildcard in my edit shortcuts that's getting confused between apps/crenshaw2-1.subx and apps/crenshaw2-1b.subx. We're pretty much always using the full filename (excluding .subx extension) anyway.
* 4772Kartik Agaram2018-11-241-1/+2
|
* 4757Kartik Agaram2018-11-201-0/+3
| | | | | | Let's start highlighting all global variables in Red. Assembly programming has a tendency to over-use them. They're a necessary evil, but we should minimize the number of functions that access them.
* 4751Kartik Agaram2018-11-181-0/+6
|
* 4726Kartik Agaram2018-10-271-0/+3
|
* 4725 - back to porting the Crenshaw compilerKartik Agaram2018-10-261-0/+9
|
* 4673Kartik Agaram2018-10-071-2/+2
| | | | | To search for instructions in .subx files, just run `:G 8b.*copy` inside Vim without any quotes.
* 4672Kartik Agaram2018-10-071-0/+8
|
* 4570Kartik Agaram2018-09-211-4/+16
|
* 4568Kartik Agaram2018-09-211-1/+5
| | | | Get the 'edit' script working again with the 'EE' command in Vim.
* 4474Kartik Agaram2018-08-041-8/+1
|
* 4323Kartik Agaram2018-07-071-0/+13
|
* 4299Kartik Agaram2018-06-301-2/+1
|
* 4262 - literal 'null'Kartik Agaram2018-06-171-1/+2
|
* 4261 - start using literals for 'true' and 'false'Kartik Agaram2018-06-171-0/+1
| | | | | | | | | They uncovered one bug: in edit/003-shortcuts.mu <scroll-down> was returning 0 for an address in one place where I thought it was returning 0 for a boolean. Now we've eliminated this bad interaction between tangling and punning literals.
* 3976Kartik K. Agaram2017-08-201-1/+0
|
* 3707Kartik K. Agaram2016-12-121-1/+3
| | | | | | | | | | | | | | | | | | Be more disciplined about tagging 2 different concepts in the codebase: a) Use the phrase "later layers" to highlight places where a layer doesn't have the simplest possible self-contained implementation. b) Use the word "hook" to point out functions that exist purely to provide waypoints for extension by future layers. Since both these only make sense in the pre-tangled representation of the codebase, using '//:' and '#:' comments to get them stripped out of tangled output. (Though '#:' comments still make it to tangled output at the moment. Let's see if we use it enough to be worth supporting. Scenarios are pretty unreadable in tangled output anyway.)
* 3566Kartik K. Agaram2016-10-231-3/+4
| | | | | | | | | | | | vim: Stop loading C++-specific syntax highlighting in non-C++ files. I also figured out why the autocommand wasn't running on the first file: my local setup for directory-specific vimrc files runs inside an autocommand, and it runs autocommands recursively inside an autocommand, and it runs only autocommands inside a 'LocalVimrc' autocommand group to ensure infinite regress (autocommands running multiple times in practice). And I'd forgotten this 'feature' of my vimrc setup by the time I set this up for Mu.
* 3561Kartik K. Agaram2016-10-221-2/+2
|
* 3431Kartik K. Agaram2016-09-301-0/+12
| | | | | Improvements to syntax highlighting, particularly for Mu code in C++ files.
* 1555 - mu.vim: distinguish control-flow from constantsKartik K. Agaram2015-06-121-2/+1
| | | | We also do this in regular C++ now.
* 1297Kartik K. Agaram2015-05-071-5/+8
|
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-6/+34
| | | | I've tried to update the Readme, but there are at least a couple of issues.
* 1150Kartik K. Agaram2015-04-231-1/+0
|
* 1093 - little more vim support for the old arc versionKartik K. Agaram2015-04-171-0/+8
|
* 744 - test cursor movement in trace browserKartik K. Agaram2015-02-111-0/+1
Don't prevent run-code from clobbering existing functions, but warn because it makes traces easier to read if the different sections of a test can be distinguished.
or: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#include "xmpp/xmpp.h"

#include "ui/ui.h"
#include "ui/stub_ui.h"

#include "config/accounts.h"

#include "command/commands.h"

#define CMD_ACCOUNT "/account"

void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
{
    gchar *args[] = { NULL };

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}


void cmd_account_shows_account_when_connected_and_no_args(void **state)
{
    ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    gchar *args[] = { NULL };

    will_return(jabber_get_connection_status, JABBER_CONNECTED);
    will_return(jabber_get_account_name, "account_name");
    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_memory(cons_show_account, account, account, sizeof(ProfAccount));

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_list_shows_accounts(void **state)
{
    gchar *args[] = { "list", NULL };

    gchar **accounts = malloc(sizeof(gchar *) * 4);
    accounts[0] = strdup("account1");
    accounts[1] = strdup("account2");
    accounts[2] = strdup("account3");
    accounts[3] = NULL;

    will_return(accounts_get_list, accounts);

    expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_show_shows_usage_when_no_arg(void **state)
{
    gchar *args[] = { "show", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
{
    gchar *args[] = { "show", "account_name", NULL };

    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, NULL);

    expect_cons_show("No such account.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_show_shows_account_when_exists(void **state)
{
    gchar *args[] = { "show", "account_name", NULL };
    ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_memory(cons_show_account, account, account, sizeof(account));

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_add_shows_usage_when_no_arg(void **state)
{
    gchar *args[] = { "add", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_add_adds_account(void **state)
{
    gchar *args[] = { "add", "new_account", NULL };

    expect_string(accounts_add, jid, "new_account");
    expect_value(accounts_add, altdomain, NULL);
    expect_value(accounts_add, port, 0);
    expect_cons_show("Account created.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_enable_shows_usage_when_no_arg(void **state)
{
    gchar *args[] = { "enable", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_enable_enables_account(void **state)
{
    gchar *args[] = { "enable", "account_name", NULL };

    expect_string(accounts_enable, name, "account_name");
    will_return(accounts_enable, TRUE);

    expect_cons_show("Account enabled.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
{
    gchar *args[] = { "enable", "account_name", NULL };

    expect_any(accounts_enable, name);
    will_return(accounts_enable, FALSE);

    expect_cons_show("No such account: account_name");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_disable_shows_usage_when_no_arg(void **state)
{
    gchar *args[] = { "disable", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_disable_disables_account(void **state)
{
    gchar *args[] = { "disable", "account_name", NULL };

    expect_string(accounts_disable, name, "account_name");
    will_return(accounts_disable, TRUE);

    expect_cons_show("Account disabled.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
{
    gchar *args[] = { "disable", "account_name", NULL };

    expect_any(accounts_disable, name);
    will_return(accounts_disable, FALSE);

    expect_cons_show("No such account: account_name");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_rename_shows_usage_when_no_args(void **state)
{
    gchar *args[] = { "rename", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_rename_shows_usage_when_one_arg(void **state)
{
    gchar *args[] = { "rename", "original_name", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_rename_renames_account(void **state)
{
    gchar *args[] = { "rename", "original_name", "new_name", NULL };

    expect_string(accounts_rename, account_name, "original_name");
    expect_string(accounts_rename, new_name, "new_name");
    will_return(accounts_rename, TRUE);

    expect_cons_show("Account renamed.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_rename_shows_message_when_not_renamed(void **state)
{
    gchar *args[] = { "rename", "original_name", "new_name", NULL };

    expect_any(accounts_rename, account_name);
    expect_any(accounts_rename, new_name);
    will_return(accounts_rename, FALSE);

    expect_cons_show("Either account original_name doesn't exist, or account new_name already exists.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_shows_usage_when_no_args(void **state)
{
    gchar *args[] = { "set", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_shows_usage_when_one_arg(void **state)
{
    gchar *args[] = { "set", "a_account", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_shows_usage_when_two_args(void **state)
{
    gchar *args[] = { "set", "a_account", "a_property", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_shows_message_when_account_doesnt_exist(void **state)
{
    gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL };

    expect_string(accounts_account_exists, account_name, "a_account");
    will_return(accounts_account_exists, FALSE);

    expect_cons_show("Account a_account doesn't exist");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
{
    gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Malformed jid: @malformed");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_jid_sets_barejid(void **state)
{
    gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_jid, account_name, "a_account");
    expect_string(accounts_set_jid, value, "a_local@a_domain");

    expect_cons_show("Updated jid for account a_account: a_local@a_domain");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_jid_sets_resource(void **state)
{
    gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_jid, account_name, "a_account");
    expect_string(accounts_set_jid, value, "a_local@a_domain");

    expect_cons_show("Updated jid for account a_account: a_local@a_domain");

    expect_string(accounts_set_resource, account_name, "a_account");
    expect_string(accounts_set_resource, value, "a_resource");

    expect_cons_show("Updated resource for account a_account: a_resource");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_server_sets_server(void **state)
{
    gchar *args[] = { "set", "a_account", "server", "a_server", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_server, account_name, "a_account");
    expect_string(accounts_set_server, value, "a_server");

    expect_cons_show("Updated server for account a_account: a_server");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_resource_sets_resource(void **state)
{
    gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_resource, account_name, "a_account");
    expect_string(accounts_set_resource, value, "a_resource");

    expect_cons_show("Updated resource for account a_account: a_resource");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_resource_sets_resource_with_online_message(void **state)
{
    gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };

    will_return(jabber_get_connection_status, JABBER_CONNECTED);

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_resource, account_name, "a_account");
    expect_string(accounts_set_resource, value, "a_resource");

    expect_cons_show("Updated resource for account a_account: a_resource, you will need to reconnect to pick up the change.");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_password_sets_password(void **state)
{
    gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
    ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);


    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_get_account, name, "a_account");
    will_return(accounts_get_account, account);

    expect_string(accounts_set_password, account_name, "a_account");
    expect_string(accounts_set_password, value, "a_password");

    expect_cons_show("Updated password for account a_account");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_eval_password_sets_eval_password(void **state)
{
    gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
    ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_get_account, name, "a_account");
    will_return(accounts_get_account, account);

    expect_string(accounts_set_eval_password, account_name, "a_account");
    expect_string(accounts_set_eval_password, value, "a_password");

    expect_cons_show("Updated eval_password for account a_account");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_password_when_eval_password_set(void **state) {
    gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
    ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_get_account, name, "a_account");
    will_return(accounts_get_account, account);

    expect_cons_show("Cannot set password when eval_password is set.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_eval_password_when_password_set(void **state) {
    gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
    ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_get_account, name, "a_account");
    will_return(accounts_get_account, account);

    expect_cons_show("Cannot set eval_password when password is set.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_muc_sets_muc(void **state)
{
    gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_muc_service, account_name, "a_account");
    expect_string(accounts_set_muc_service, value, "a_muc");

    expect_cons_show("Updated muc service for account a_account: a_muc");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_nick_sets_nick(void **state)
{
    gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_muc_nick, account_name, "a_account");
    expect_string(accounts_set_muc_nick, value, "a_nick");

    expect_cons_show("Updated muc nick for account a_account: a_nick");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_show_message_for_missing_otr_policy(void **state)
{
    gchar *args[] = { "set", "a_account", "otr", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_show_message_for_invalid_otr_policy(void **state)
{
    gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("OTR policy must be one of: manual, opportunistic or always.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_otr_sets_otr(void **state)
{
    gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_otr_policy, account_name, "a_account");
    expect_string(accounts_set_otr_policy, value, "opportunistic");

    expect_cons_show("Updated OTR policy for account a_account: opportunistic");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_status_shows_message_when_invalid_status(void **state)
{
    gchar *args[] = { "set", "a_account", "status", "bad_status", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Invalid status: bad_status");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_status_sets_status_when_valid(void **state)
{
    gchar *args[] = { "set", "a_account", "status", "away", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_login_presence, account_name, "a_account");
    expect_string(accounts_set_login_presence, value, "away");

    expect_cons_show("Updated login status for account a_account: away");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_status_sets_status_when_last(void **state)
{
    gchar *args[] = { "set", "a_account", "status", "last", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_login_presence, account_name, "a_account");
    expect_string(accounts_set_login_presence, value, "last");

    expect_cons_show("Updated login status for account a_account: last");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_invalid_presence_string_priority_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "blah", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Invalid property: blah");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_last_priority_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "last", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Invalid property: last");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_online_priority_sets_preference(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_priority_online, account_name, "a_account");
    expect_value(accounts_set_priority_online, value, 10);

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_cons_show("Updated online priority for account a_account: 10");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_chat_priority_sets_preference(void **state)
{
    gchar *args[] = { "set", "a_account", "chat", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_priority_chat, account_name, "a_account");
    expect_value(accounts_set_priority_chat, value, 10);

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_cons_show("Updated chat priority for account a_account: 10");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_away_priority_sets_preference(void **state)
{
    gchar *args[] = { "set", "a_account", "away", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_priority_away, account_name, "a_account");
    expect_value(accounts_set_priority_away, value, 10);

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_cons_show("Updated away priority for account a_account: 10");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_xa_priority_sets_preference(void **state)
{
    gchar *args[] = { "set", "a_account", "xa", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_priority_xa, account_name, "a_account");
    expect_value(accounts_set_priority_xa, value, 10);

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_cons_show("Updated xa priority for account a_account: 10");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_dnd_priority_sets_preference(void **state)
{
    gchar *args[] = { "set", "a_account", "dnd", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_string(accounts_set_priority_dnd, account_name, "a_account");
    expect_value(accounts_set_priority_dnd, value, 10);

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_cons_show("Updated dnd priority for account a_account: 10");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_priority_too_low_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "-150", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Value -150 out of range. Must be in -128..127.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_priority_too_high_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "150", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Value 150 out of range. Must be in -128..127.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_priority_when_not_number_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "abc", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Could not convert \"abc\" to a number.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_priority_when_empty_shows_message(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Could not convert \"\" to a number.");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state)
{
    gchar *args[] = { "set", "a_account", "online", "10", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_any(accounts_set_priority_online, account_name);
    expect_any(accounts_set_priority_online, value);

    will_return(jabber_get_connection_status, JABBER_CONNECTED);

    expect_any(accounts_get_last_presence, account_name);
    will_return(accounts_get_last_presence, RESOURCE_ONLINE);

    will_return(jabber_get_account_name, "a_account");

#ifdef HAVE_LIBGPGME
    ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource",
        NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    will_return(jabber_get_account_name, "a_account");
    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);
#endif

    will_return(jabber_get_presence_message, "Free to chat");

    expect_value(presence_send, status, RESOURCE_ONLINE);
    expect_string(presence_send, msg, "Free to chat");
    expect_value(presence_send, idle, 0);
    expect_value(presence_send, signed_status, NULL);

    expect_cons_show("Updated online priority for account a_account: 10");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_clear_shows_usage_when_no_args(void **state)
{
    gchar *args[] = { "clear", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_clear_shows_usage_when_one_arg(void **state)
{
    gchar *args[] = { "clear", "a_account", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
{
    gchar *args[] = { "clear", "a_account", "a_property", NULL };

    expect_string(accounts_account_exists, account_name, "a_account");
    will_return(accounts_account_exists, FALSE);

    expect_cons_show("Account a_account doesn't exist");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}

void cmd_account_clear_shows_message_when_invalid_property(void **state)
{
    gchar *args[] = { "clear", "a_account", "badproperty", NULL };

    expect_any(accounts_account_exists, account_name);
    will_return(accounts_account_exists, TRUE);

    expect_cons_show("Invalid property: badproperty");
    expect_cons_show("");

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}