forked from cory/tildefriends
test: Add some nominal testing for the new publish command.
This commit is contained in:
parent
82d1a294a6
commit
94e8bf2e1c
@ -980,4 +980,40 @@ void tf_ssb_test_peer_exchange(const tf_test_options_t* options)
|
|||||||
uv_loop_close(&loop);
|
uv_loop_close(&loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tf_ssb_test_publish(const tf_test_options_t* options)
|
||||||
|
{
|
||||||
|
uv_loop_t loop = { 0 };
|
||||||
|
uv_loop_init(&loop);
|
||||||
|
|
||||||
|
unlink("out/test_db0.sqlite");
|
||||||
|
tf_ssb_t* ssb = tf_ssb_create(&loop, NULL, "file:out/test_db0.sqlite", NULL);
|
||||||
|
tf_ssb_register(tf_ssb_get_context(ssb), ssb);
|
||||||
|
|
||||||
|
char id[k_id_base64_len] = { 0 };
|
||||||
|
tf_ssb_whoami(ssb, id, sizeof(id));
|
||||||
|
|
||||||
|
char executable[1024];
|
||||||
|
size_t size = sizeof(executable);
|
||||||
|
uv_exepath(executable, &size);
|
||||||
|
|
||||||
|
char command[4096];
|
||||||
|
snprintf(command, sizeof(command), "%s publish -d out/test_db0.sqlite -u :admin -i %s -c '{\"type\": \"post\", \"text\": \"One.\"}'", executable, id);
|
||||||
|
int result = system(command);
|
||||||
|
(void)result;
|
||||||
|
assert(WIFEXITED(result));
|
||||||
|
printf("returned %d\n", WEXITSTATUS(result));
|
||||||
|
assert(WEXITSTATUS(result) == 0);
|
||||||
|
|
||||||
|
snprintf(command, sizeof(command), "%s publish -d out/test_db0.sqlite -u :admin -i %s -c '{\"type\": \"post\", \"text\": \"Two.\"}'", executable, id);
|
||||||
|
result = system(command);
|
||||||
|
assert(WIFEXITED(result));
|
||||||
|
printf("returned %d\n", WEXITSTATUS(result));
|
||||||
|
assert(WEXITSTATUS(result) == 0);
|
||||||
|
|
||||||
|
tf_ssb_destroy(ssb);
|
||||||
|
|
||||||
|
uv_run(&loop, UV_RUN_DEFAULT);
|
||||||
|
uv_loop_close(&loop);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,4 +59,10 @@ void tf_ssb_test_encrypt(const tf_test_options_t* options);
|
|||||||
*/
|
*/
|
||||||
void tf_ssb_test_peer_exchange(const tf_test_options_t* options);
|
void tf_ssb_test_peer_exchange(const tf_test_options_t* options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
** Test publishing a message.
|
||||||
|
** @param options The test options.
|
||||||
|
*/
|
||||||
|
void tf_ssb_test_publish(const tf_test_options_t* options);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -916,6 +916,7 @@ void tf_tests(const tf_test_options_t* options)
|
|||||||
_tf_test_run(options, "go-ssb-room", tf_ssb_test_go_ssb_room, true);
|
_tf_test_run(options, "go-ssb-room", tf_ssb_test_go_ssb_room, true);
|
||||||
_tf_test_run(options, "encrypt", tf_ssb_test_encrypt, false);
|
_tf_test_run(options, "encrypt", tf_ssb_test_encrypt, false);
|
||||||
_tf_test_run(options, "peer_exchange", tf_ssb_test_peer_exchange, false);
|
_tf_test_run(options, "peer_exchange", tf_ssb_test_peer_exchange, false);
|
||||||
|
_tf_test_run(options, "publish", tf_ssb_test_publish, false);
|
||||||
tf_printf("Tests completed.\n");
|
tf_printf("Tests completed.\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user