test: More CLI tests, and make -u optional for publish, too.
Some checks failed
Build Tilde Friends / Build-All (push) Failing after 5m11s
Some checks failed
Build Tilde Friends / Build-All (push) Failing after 5m11s
This commit is contained in:
@ -1478,7 +1478,7 @@ void tf_ssb_test_triggers(const tf_test_options_t* options)
|
||||
uv_loop_close(&loop);
|
||||
}
|
||||
|
||||
static void _subprocess_check_call(const char* command)
|
||||
static void _subprocess_check_call(const char* command, int expected)
|
||||
{
|
||||
int result = system(command);
|
||||
if (!WIFEXITED(result))
|
||||
@ -1486,9 +1486,9 @@ static void _subprocess_check_call(const char* command)
|
||||
tf_printf("Command did not report exit: %s.\n", command);
|
||||
abort();
|
||||
}
|
||||
if (WEXITSTATUS(result) != 0)
|
||||
if (WEXITSTATUS(result) != expected)
|
||||
{
|
||||
tf_printf("Command returned %d: %s.\n", WEXITSTATUS(result), command);
|
||||
tf_printf("Command returned %d (expected %d): %s.\n", WEXITSTATUS(result), expected, command);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
@ -1558,13 +1558,53 @@ void tf_ssb_test_cli(const tf_test_options_t* options)
|
||||
|
||||
char command[1024];
|
||||
snprintf(command, sizeof(command), "%s get_identity -d out/test_db0.sqlite", options->exe_path);
|
||||
_subprocess_check_call(command);
|
||||
_subprocess_check_call(command, 0);
|
||||
char* id = _trim(_subprocess_check_output(command));
|
||||
tf_printf("id = [%s]\n", id);
|
||||
|
||||
snprintf(command, sizeof(command), "%s private -i %s -r %s -d out/test_db0.sqlite -t '{\"type\": \"post\", \"text\": \"hello world\"}'", options->exe_path, id, id);
|
||||
_subprocess_check_call(command);
|
||||
snprintf(command, sizeof(command), "%s publish -i %s -d out/test_db0.sqlite -c '{\"type\": \"about\", \"about\": \"%s\", \"name\": \"test_user\"}'", options->exe_path, id, id);
|
||||
_subprocess_check_call(command, 0);
|
||||
|
||||
snprintf(command, sizeof(command), "%s private -i %s -r %s -d out/test_db0.sqlite -t '{\"type\": \"post\", \"text\": \"hello world\"}'", options->exe_path, id, id);
|
||||
_subprocess_check_call(command, 0);
|
||||
|
||||
snprintf(command, sizeof(command), "%s verify -i %s -d out/test_db0.sqlite", options->exe_path, id);
|
||||
_subprocess_check_call(command, 0);
|
||||
|
||||
snprintf(command, sizeof(command), "%s store_blob -f GNUmakefile -d out/test_db0.sqlite", options->exe_path);
|
||||
char* blob = _trim(_subprocess_check_output(command));
|
||||
|
||||
snprintf(command, sizeof(command), "%s has_blob -b '%s' -d out/test_db0.sqlite", options->exe_path, blob);
|
||||
_subprocess_check_call(command, 0);
|
||||
|
||||
snprintf(command, sizeof(command), "%s has_blob -b '&nonexistentid.sha256' -d out/test_db0.sqlite", options->exe_path);
|
||||
_subprocess_check_call(command, EXIT_FAILURE);
|
||||
|
||||
snprintf(command, sizeof(command), "%s get_sequence -i %s -d out/test_db0.sqlite", options->exe_path, id);
|
||||
char* sequence = _trim(_subprocess_check_output(command));
|
||||
if (strcmp(sequence, "2") != 0)
|
||||
{
|
||||
tf_printf("sequence = %s (expected 1)\n", sequence);
|
||||
abort();
|
||||
}
|
||||
tf_free(sequence);
|
||||
|
||||
snprintf(command, sizeof(command), "%s get_profile -i %s -d out/test_db0.sqlite", options->exe_path, id);
|
||||
char* profile = _trim(_subprocess_check_output(command));
|
||||
const char* k_expected_profile = "{\"name\":\"test_user\"}";
|
||||
if (strcmp(profile, k_expected_profile) != 0)
|
||||
{
|
||||
tf_printf("profile = %s (expected \"%s\")\n", profile, k_expected_profile);
|
||||
abort();
|
||||
}
|
||||
tf_free(profile);
|
||||
|
||||
snprintf(command, sizeof(command), "%s get_contacts -i %s -d out/test_db0.sqlite", options->exe_path, id);
|
||||
char* contacts = _trim(_subprocess_check_output(command));
|
||||
tf_printf("contacts = %s\n", contacts);
|
||||
tf_free(contacts);
|
||||
|
||||
tf_free(blob);
|
||||
tf_free(id);
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user