[asterisk-commits] dlee: branch dlee/stasis-http r380650 - /team/dlee/stasis-http/tests/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 31 11:16:50 CST 2013
Author: dlee
Date: Thu Jan 31 11:16:47 2013
New Revision: 380650
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380650
Log:
Test app replacement
Modified:
team/dlee/stasis-http/tests/test_stasis_core.c
Modified: team/dlee/stasis-http/tests/test_stasis_core.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/tests/test_stasis_core.c?view=diff&rev=380650&r1=380649&r2=380650
==============================================================================
--- team/dlee/stasis-http/tests/test_stasis_core.c (original)
+++ team/dlee/stasis-http/tests/test_stasis_core.c Thu Jan 31 11:16:47 2013
@@ -123,15 +123,59 @@
return AST_TEST_PASS;
}
+AST_TEST_DEFINE(app_replaced)
+{
+ RAII_VAR(struct app_data *, app_data1, NULL, app_data_dtor);
+ RAII_VAR(struct app_data *, app_data2, NULL, app_data_dtor);
+ RAII_VAR(char *, app_name, "test-handler", stasis_app_unregister);
+ RAII_VAR(struct ast_json *, expected_message1, NULL, ast_json_unref);
+ RAII_VAR(struct ast_json *, expected_message2, NULL, ast_json_unref);
+ int res;
+
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = __func__;
+ info->category = "/stasis/core/";
+ info->summary = "Test stasis app invocation.";
+ info->description = "Test stasis app invocation.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ app_data1 = app_data_create();
+ app_data2 = app_data_create();
+
+ stasis_app_register(app_name, test_handler, app_data1);
+ stasis_app_register(app_name, test_handler, app_data2);
+ expected_message1 = ast_json_pack("[{s: s}]", "event", "replaced");
+ expected_message2 = ast_json_pack("[{s: s, s: o, s: []}]",
+ "command", "invoke",
+ "channel", ast_json_null(),
+ "args");
+
+ res = stasis_app_invoke(app_name, NULL, 0, NULL);
+ ast_test_validate(test, 0 == res);
+ ast_test_validate(test, 1 == app_data1->invocations);
+ ast_test_validate(test, ast_json_equal(expected_message1, app_data1->messages));
+ ast_test_validate(test, 1 == app_data2->invocations);
+ ast_test_validate(test, ast_json_equal(expected_message2, app_data2->messages));
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(app_invoke_dne);
AST_TEST_UNREGISTER(app_invoke_one);
+ AST_TEST_UNREGISTER(app_replaced);
return 0;
}
static int load_module(void)
{
+ AST_TEST_REGISTER(app_replaced);
AST_TEST_REGISTER(app_invoke_one);
AST_TEST_REGISTER(app_invoke_dne);
return AST_MODULE_LOAD_SUCCESS;
More information about the asterisk-commits
mailing list