[asterisk-commits] dlee: branch dlee/stasis-http r379263 - /team/dlee/stasis-http/tests/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 16 12:28:11 CST 2013


Author: dlee
Date: Wed Jan 16 12:28:07 2013
New Revision: 379263

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379263
Log:
Wildcard and delete tests

Modified:
    team/dlee/stasis-http/tests/test_stasis_http.c

Modified: team/dlee/stasis-http/tests/test_stasis_http.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/tests/test_stasis_http.c?view=diff&rev=379263&r1=379262&r2=379263
==============================================================================
--- team/dlee/stasis-http/tests/test_stasis_http.c (original)
+++ team/dlee/stasis-http/tests/test_stasis_http.c Wed Jan 16 12:28:07 2013
@@ -340,6 +340,76 @@
 	return AST_TEST_PASS;
 }
 
+AST_TEST_DEFINE(invoke_wildcard)
+{
+	RAII_VAR(void *, fixture, setup_invocation_test(), tear_down_invocation_test);
+	RAII_VAR(struct stasis_http_response *, response, response_alloc(), response_free);
+	RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
+	struct ast_variable *get_params = NULL;
+	struct ast_variable *headers = NULL;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = __func__;
+		info->category = "/stasis/http/";
+		info->summary = "Test simple GET of an HTTP resource.";
+		info->description = "Test Stasis HTTP binding logic.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	expected = ast_json_pack("{s: s, s: {}, s: {}, s: {s: s}}",
+				 "name", "bam_get",
+				 "get_params",
+				 "headers",
+				 "path_vars",
+				 "bam", "foshizzle");
+
+	stasis_http_invoke("foo/foshizzle", AST_HTTP_GET, get_params, headers, response);
+
+	ast_test_validate(test, 1 == invocation_count);
+	ast_test_validate(test, 200 == response->response_code);
+	ast_test_validate(test, ast_json_equal(expected, response->message));
+
+	return AST_TEST_PASS;
+}
+
+AST_TEST_DEFINE(invoke_delete)
+{
+	RAII_VAR(void *, fixture, setup_invocation_test(), tear_down_invocation_test);
+	RAII_VAR(struct stasis_http_response *, response, response_alloc(), response_free);
+	RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
+	struct ast_variable *get_params = NULL;
+	struct ast_variable *headers = NULL;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = __func__;
+		info->category = "/stasis/http/";
+		info->summary = "Test simple GET of an HTTP resource.";
+		info->description = "Test Stasis HTTP binding logic.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	expected = ast_json_pack("{s: s, s: {}, s: {}, s: {s: s}}",
+				 "name", "bang_delete",
+				 "get_params",
+				 "headers",
+				 "path_vars",
+				 "bam", "foshizzle");
+
+	stasis_http_invoke("foo/foshizzle/bang", AST_HTTP_DELETE, get_params, headers, response);
+
+	ast_test_validate(test, 1 == invocation_count);
+	ast_test_validate(test, 204 == response->response_code);
+	ast_test_validate(test, ast_json_equal(expected, response->message));
+
+	return AST_TEST_PASS;
+}
+
 AST_TEST_DEFINE(invoke_post)
 {
 	RAII_VAR(void *, fixture, setup_invocation_test(), tear_down_invocation_test);
@@ -421,6 +491,8 @@
 	AST_TEST_UNREGISTER(get_api_notfound);
 	AST_TEST_UNREGISTER(get_api_hackerz);
 	AST_TEST_UNREGISTER(invoke_get);
+	AST_TEST_UNREGISTER(invoke_wildcard);
+	AST_TEST_UNREGISTER(invoke_delete);
 	AST_TEST_UNREGISTER(invoke_post);
 	AST_TEST_UNREGISTER(invoke_bad_post);
 	return 0;
@@ -433,6 +505,8 @@
 	AST_TEST_REGISTER(get_api_notfound);
 	AST_TEST_REGISTER(get_api_hackerz);
 	AST_TEST_REGISTER(invoke_get);
+	AST_TEST_REGISTER(invoke_wildcard);
+	AST_TEST_REGISTER(invoke_delete);
 	AST_TEST_REGISTER(invoke_post);
 	AST_TEST_REGISTER(invoke_bad_post);
 	return AST_MODULE_LOAD_SUCCESS;




More information about the asterisk-commits mailing list